参考:http://d.hatena.ne.jp/peroon/20091123/1258966199
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> using namespace std; //math //------------------------------------------- template<class T> inline T sqr(T x) {return x*x;} //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //map関係(連想配列) /************************** 使用例<string , string>の時 MSS hoge; hoge.insert(MP("hoge","hogehoge")); dump(hoge["hoge"]); **************************/ typedef map<int,int> MII; typedef map<int,string> MIS; typedef map<string,int> MSI; typedef map<string,string> MSS; //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //cin_i() で cin >> nと同等 inline int cin_i() {int n;cin >> n;return n;} //cin_s() で cin >> sと同等 inline string cin_s() {string s;cin >> s;return s;} //getl_s() で getline(cin,s)と同等 inline string getl_s() {string s;getline(cin , s);return s;} //limit分cinを取ってくる vector<int>で返す inline VI VI_cin(int limit) {VI r;REP(i,limit) {r.PB(cin_i());}return r;} inline VS VS_cin(int limit) {VS r;REP(i,limit) {r.PB(cin_s());}return r;} /**************************** ここから処理書く ****************************/