[ create a new paste ] login | about

Link: http://codepad.org/q3aphnM9    [ raw code | fork ]

C++, pasted on Feb 5:
#include <iostream>
#include <string>
#include <chrono>
#include <array>
#include <vector>
#include <tuple>
#include <queue>
#include <utility>

#define forx(n) for (uint i = 0; i < n; ++i)
#define sc static_cast

using uint = uint32_t;
using real = double;
using namespace std;
using namespace std::chrono;

struct stopwatch {
    time_point<high_resolution_clock> s;
    stopwatch () {
        s = high_resolution_clock::now();
    }
    void start () {
        s = high_resolution_clock::now();    
    }
    uint mark () {
        return duration_cast<seconds> (high_resolution_clock::now() - s).count();
    } 

};

template <typename T1>
inline
auto matrix (uint size, uint size2 = 0) -> vector<vector<T1>> {
    if (size2 == 0) 
        return vector<vector<T1>> (size, vector<T1>(size));
    return vector<vector<T1>> (size, vector<T1>(size2));
}

template <typename T1>
void print (T1 container) {
    for (const auto &element : container)
        cout << element << " ";
    cout << "\n";
}

template <typename T1>
void print (vector<vector<T1>> container) {
    for (const auto &row : container) {
        for (const auto &element : row)
            cout << element << " ";
        cout << "\n";
    }
}

template<typename T1, typename T2>
ostream& operator << (ostream& strm, const pair<T1, T2>& p) {
    return strm << "{" << p.first << "," << p.second << "}\n";
}

inline
auto x100 (real num) -> uint {
    return static_cast<uint>(num * 100);
}

inline
auto d100 (uint num) -> real {
    return num / 100.0;
}


Create a new paste based on this one


Comments: