Created
July 9, 2013 15:31
-
-
Save lychees/5958321 to your computer and use it in GitHub Desktop.
WTF.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Micro Mezz Macro Flation -- Overheated Economy ., Last Update: Jun. 26th 2013 **/ //{ | |
/** Header .. **/ //{ | |
#include <functional> | |
#include <algorithm> | |
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <iomanip> | |
#include <numeric> | |
#include <cstring> | |
#include <climits> | |
#include <cassert> | |
#include <cstdio> | |
#include <string> | |
#include <vector> | |
#include <bitset> | |
#include <queue> | |
#include <stack> | |
#include <cmath> | |
#include <ctime> | |
#include <list> | |
#include <set> | |
#include <map> | |
//#include <tr1/unordered_set> | |
//#include <tr1/unordered_map> | |
//#include <array> | |
using namespace std; | |
#define REP(i, n) for (int i=0;i<int(n);++i) | |
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i) | |
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i) | |
#define REP_1(i, n) for (int i=1;i<=int(n);++i) | |
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i) | |
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i) | |
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i) | |
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i) | |
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i) | |
#define REP_N(i, n) for (i=0;i<int(n);++i) | |
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i) | |
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i) | |
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i) | |
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i) | |
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i) | |
#define REP_1_N(i, n) for (i=1;i<=int(n);++i) | |
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i) | |
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i) | |
#define REP_C_N(i, n) for (int n____=(i=0,int(n));i<n____;++i) | |
#define FOR_C_N(i, a, b) for (int b____=(i=0,int(b);i<b____;++i) | |
#define DWN_C_N(i, b, a) for (int a____=(i=b-1,int(a));i>=a____;--i) | |
#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i) | |
#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i) | |
#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i) | |
#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it) | |
#define REP_S(i, str) for (char*i=str;*i;++i) | |
#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i]) | |
#define REP_G(i, u) REP_L(i,hd[u],suc) | |
#define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) | |
#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; ) | |
#define REP_2(i, j, n, m) REP(i, n) REP(j, m) | |
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) | |
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) | |
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) | |
#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) | |
#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) | |
#define ALL(A) A.begin(), A.end() | |
#define LLA(A) A.rbegin(), A.rend() | |
#define CPY(A, B) memcpy(A, B, sizeof(A)) | |
#define INS(A, P, B) A.insert(A.begin() + P, B) | |
#define ERS(A, P) A.erase(A.begin() + P) | |
#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin()) | |
#define CTN(T, x) (T.find(x) != T.end()) | |
#define SZ(A) int((A).size()) | |
#define PB push_back | |
#define MP(A, B) make_pair(A, B) | |
#define PTT pair<T, T> | |
#define fi first | |
#define se second | |
#define Rush for(int ____T=RD(); ____T--;) | |
#define Display(A, n, m) { \ | |
REP(i, n){ \ | |
REP(j, m-1) cout << A[i][j] << " "; \ | |
cout << A[i][m-1] << endl; \ | |
} \ | |
} | |
#define Display_1(A, n, m) { \ | |
REP_1(i, n){ \ | |
REP_1(j, m-1) cout << A[i][j] << " "; \ | |
cout << A[i][m] << endl; \ | |
} \ | |
} | |
string __file__(){ | |
string res = __FILE__; | |
int r = SZ(res) - 1; while (res[r] != '.') --r; | |
int l = r - 1; while (res[l] != '\\') --l; ++l; | |
return res.substr(l, r-l); | |
} | |
void Exec(string a, string b, string c){ | |
if (b.empty()) b = __file__(); | |
string cmd = a + ' ' + b + '.' + c; | |
system(cmd.c_str()); | |
} | |
void Ruby(string file = ""){Exec("ruby", file, "rb");} | |
void Python(string file = ""){Exec("python", file, "py");} | |
void Haskell(string file = ""){Exec("runghc", file, "hs");} | |
void Pascal(string file = ""){Exec("pascal", file, "pas");} | |
void Ocaml(string file = ""){Exec("ocaml", file, "ml");} | |
typedef long long LL; | |
//typedef long double DB; | |
typedef double DB; | |
typedef unsigned UINT; | |
typedef unsigned long long ULL; | |
typedef vector<int> VI; | |
typedef vector<char> VC; | |
typedef vector<string> VS; | |
typedef vector<LL> VL; | |
typedef vector<DB> VF; | |
typedef set<int> SI; | |
typedef set<string> SS; | |
typedef map<int, int> MII; | |
typedef map<string, int> MSI; | |
typedef pair<int, int> PII; | |
typedef pair<LL, LL> PLL; | |
typedef vector<PII> VII; | |
typedef vector<VI> VVI; | |
typedef vector<VII> VVII; | |
template<class T> inline T& RD(T &); | |
template<class T> inline void OT(const T &); | |
//inline int RD(){int x; return RD(x);} | |
inline LL RD(){LL x; return RD(x);} | |
inline DB& RF(DB &); | |
inline DB RF(){DB x; return RF(x);} | |
inline char* RS(char *s); | |
inline char& RC(char &c); | |
inline char RC(); | |
inline char& RC(char &c){scanf(" %c", &c); return c;} | |
inline char RC(){char c; return RC(c);} | |
//inline char& RC(char &c){c = getchar(); return c;} | |
//inline char RC(){return getchar();} | |
template<class T> inline T& RDD(T &x){ | |
char c; for (c = getchar(); c < '-'; c = getchar()); | |
if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;} | |
else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';} | |
return x; | |
} | |
inline LL RDD(){LL x; return RDD(x);} | |
template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} | |
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} | |
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} | |
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} | |
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} | |
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} | |
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} | |
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} | |
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} | |
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} | |
inline char& RC(char &a, char &b){RC(a), RC(b); return a;} | |
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} | |
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} | |
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} | |
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} | |
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} | |
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} | |
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} | |
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} | |
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} | |
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} | |
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} | |
inline void RS(char *s1, char *s2){RS(s1), RS(s2);} | |
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} | |
template<class T0,class T1>inline void RDD(T0&a, T1&b){RDD(a),RDD(b);} | |
template<class T0,class T1,class T2>inline void RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c);} | |
template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} | |
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} | |
template<class T> inline void CLR(T &A){A.clear();} | |
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} | |
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} | |
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} | |
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} | |
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} | |
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} | |
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} | |
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} | |
template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();} | |
template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();} | |
template<class T> inline void CLR(stack<T> &S){while (!S.empty()) S.pop();} | |
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} | |
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} | |
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} | |
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} | |
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} | |
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} | |
template<class T> inline bool EPT(T &a){return a.empty();} | |
template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} | |
template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} | |
template<class T> inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;} | |
template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} | |
//} | |
/** Constant List .. **/ //{ | |
const int MOD = int(1e9) + 7; | |
//int MOD = 99990001; | |
const int INF = 0x3f3f3f3f; | |
//const UINT UINF = 0xffffffff; | |
//const LL INFF = 0x3f3f3f3f3f3f3f3fLL; | |
const DB EPS = 1e-9; | |
const DB OO = 1e20; | |
const DB PI = acos(-1.0); //M_PI; | |
const int dx[] = {-1, 0, 1, 0}; | |
const int dy[] = {0, 1, 0, -1}; | |
//} | |
/** Add On .. **/ //{ | |
//} | |
/** I/O Accelerator Interface .. **/ //{ | |
template<class T> inline T& RD(T &x){ | |
cin >> x; | |
//scanf("%d", &x); | |
//char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; | |
//char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0'; | |
return x; | |
} | |
inline DB& RF(DB &x){ | |
//cin >> x; | |
scanf("%lf", &x); | |
/*char t; while ((t=getchar())==' '||t=='\n'); x = t - '0'; | |
while ((t=getchar())!=' '&&t!='\n'&&t!='.')x*=10,x+=t-'0'; | |
if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\n')l*=0.1,x += (t-'0')*l;}*/ | |
return x; | |
} | |
inline char* RS(char *s){ | |
//gets(s); | |
scanf("%s", s); | |
return s; | |
} | |
LL last_ans; int Case; template<class T> inline void OT(const T &x){ | |
//printf("Case %d: %d\n", ++Case, x); | |
//printf("%lld ", x); | |
//printf("%d\n", x); | |
cout << x << endl; | |
//last_ans = x; | |
} | |
//} | |
//}/* .................................................................................................................................. */ | |
const int N = 109, M = 2 * N, LN = 18; | |
int n, m, nn, rt; | |
int a, b, c; | |
int main(){ | |
#ifndef ONLINE_JUDGE | |
//freopen("in.txt", "r", stdin); | |
//freopen("out.txt", "w", stdout); | |
#endif | |
int x, y, z; //RD(n, m); | |
cin >>n >> m; | |
DO(n-1){ | |
//RD(aa, bb); | |
//++i; | |
cin >> x >> y; | |
} | |
REP_1(i, n) cin >> x; cin >> x; | |
while (m--){ | |
int t; //RD(t); | |
cin >> t; | |
if (t == 1){ | |
cin >> rt; | |
} | |
else if (t == 2){ | |
cin >> x >> y >> c; | |
} | |
else { | |
cin >> x; | |
cout << 0 << endl; | |
} | |
/*switch(t){ | |
case 1: | |
//RD(rt); | |
cin >> rt; | |
break; | |
case 2: | |
cin >> x >> y >> c; | |
//RD(x, y, c); // z = lca(x, y); | |
//Modifyy(z, x), Modifyy(z, y); | |
break; | |
case 3: | |
//RD(x); | |
cin >> x; | |
cout << -1 << endl; | |
break; | |
}*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment