#include #include #include #include #include #include #include #include #include #include #include using namespace std; //dfs //O(V+E) void TopologicalSort(vector > &G, vector &res, int node, vector &visit){ if(visit[node] == true) return; visit[node] = true; for(auto itr = G[node].rbegin(); itr != G[node].rend(); itr++){ TopologicalSort(G, res, *itr, visit); } /* for(int i=0; i> n; vector> E(n); for(int i=0; i> G(n); vector in_edge(n, 0); for(;;){ string out = "?"; vector v; vector used(2*n, false); bool update = false; for(int j=0; j> in; if(v[2*j] == -1 || v[2*j+1] == -1) continue; if(in == "=") continue; if(in == "<"){ G[v[2*j]].push_back(v[2*j+1]); in_edge[v[2*j+1]]++; } if(in == ">"){ G[v[2*j+1]].push_back(v[2*j]); in_edge[v[2*j]]++; } } } assert(false); vector res; vector visit(n, false); int start = -1; for(int i=0; i