Submission #896997

#TimeUsernameProblemLanguageResultExecution timeMemory
896997LitusianoGame (APIO22_game)C++17
Compilation error
0 ms0 KiB
tdc++.h> using namespace std; #include "game.h" int k1,n1; vector<vector<int>> G,Grev, DAG; vector<int> top,used,scc; int act = 0; void dfs(int u){ if(used[u]) return; used[u] = 1; // cerr<<"START "<<u<<endl; for(int v : G[u]) dfs(v); // cerr<<"END "<<u<<endl; top.push_back(u); } void dfs1(int u){ if(used[u]) return; used[u] = 1; for(int v : Grev[u]){ dfs1(v); } scc[u] = act; } void init(int n, int k) { k1 = k; n1 = n; G.assign(n,vector<int>()); Grev = G; // cerr<<"HERE "<<n<<" "<<k<<endl; for(int i = 0; i<=k-2; i++){ G[i].push_back(i+1); Grev[i+1].push_back(i); } } int add_teleporter(int u, int v) { // if(scc.size() && scc[u] == scc[v] && scc[u] > -1) return 0; if(u == v){ if(u < k1) return 1; return 0; } G[u].push_back(v); Grev[v].push_back(u); used.assign(n1,0); scc.assign(n1,-1); top.clear(); // cerr<<"STARTING DFS OF EDGE "<<u<<" "<<v<<endl; for(int i = 0; i<n1; i++) dfs(i); // cerr<<"TOP"<<endl; // for(int i : top) cerr<<i<<" "; // cerr<<"END TOP"<<endl; used.assign(n1,0); act = 0; for(int i = top.size()-1; i>=0; i--){ if(!used[top[i]]) act++, scc[top[i]] = act, dfs1(top[i]); } set<int> hv; for(int i = 0; i<k1; i++){ hv.insert(scc[i]); } // cerr<<"STARTING SCC OF EDGE: "<<u<<" "<<v<<endl; // for(int i = 0; i<n1; i++){ // cerr<<"SCC: "<<i<<" "<<scc[i]<<endl; // } // cerr<<endl; if(hv.size() < k1) return 1; for(int i = k1; i<n1; i++){ if(hv.count(scc[i])) return 1; } return 0; }

Compilation message (stderr)

game.cpp:1:1: error: 'tdc' does not name a type
    1 | tdc++.h>
      | ^~~
game.cpp:8:1: error: 'vector' does not name a type
    8 | vector<vector<int>> G,Grev, DAG;
      | ^~~~~~
game.cpp:9:1: error: 'vector' does not name a type
    9 | vector<int> top,used,scc;
      | ^~~~~~
game.cpp: In function 'void dfs(int)':
game.cpp:12:5: error: 'used' was not declared in this scope
   12 |  if(used[u]) return;
      |     ^~~~
game.cpp:13:2: error: 'used' was not declared in this scope
   13 |  used[u] = 1;
      |  ^~~~
game.cpp:15:14: error: 'G' was not declared in this scope
   15 |  for(int v : G[u]) dfs(v);
      |              ^
game.cpp:17:2: error: 'top' was not declared in this scope
   17 |  top.push_back(u);
      |  ^~~
game.cpp: In function 'void dfs1(int)':
game.cpp:21:5: error: 'used' was not declared in this scope
   21 |  if(used[u]) return;
      |     ^~~~
game.cpp:22:2: error: 'used' was not declared in this scope
   22 |  used[u] = 1;
      |  ^~~~
game.cpp:23:14: error: 'Grev' was not declared in this scope
   23 |  for(int v : Grev[u]){
      |              ^~~~
game.cpp:26:2: error: 'scc' was not declared in this scope
   26 |  scc[u] = act;
      |  ^~~
game.cpp: In function 'void init(int, int)':
game.cpp:31:2: error: 'G' was not declared in this scope
   31 |  G.assign(n,vector<int>());
      |  ^
game.cpp:31:13: error: 'vector' was not declared in this scope
   31 |  G.assign(n,vector<int>());
      |             ^~~~~~
game.cpp:31:20: error: expected primary-expression before 'int'
   31 |  G.assign(n,vector<int>());
      |                    ^~~
game.cpp:32:2: error: 'Grev' was not declared in this scope
   32 |  Grev = G;
      |  ^~~~
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:47:2: error: 'G' was not declared in this scope
   47 |  G[u].push_back(v);
      |  ^
game.cpp:48:2: error: 'Grev' was not declared in this scope
   48 |  Grev[v].push_back(u);
      |  ^~~~
game.cpp:49:2: error: 'used' was not declared in this scope
   49 |  used.assign(n1,0);
      |  ^~~~
game.cpp:50:2: error: 'scc' was not declared in this scope
   50 |  scc.assign(n1,-1);
      |  ^~~
game.cpp:51:2: error: 'top' was not declared in this scope
   51 |  top.clear();
      |  ^~~
game.cpp:63:2: error: 'set' was not declared in this scope
   63 |  set<int> hv;
      |  ^~~
game.cpp:63:6: error: expected primary-expression before 'int'
   63 |  set<int> hv;
      |      ^~~
game.cpp:65:3: error: 'hv' was not declared in this scope; did you mean 'v'?
   65 |   hv.insert(scc[i]);
      |   ^~
      |   v
game.cpp:72:5: error: 'hv' was not declared in this scope; did you mean 'v'?
   72 |  if(hv.size() < k1) return 1;
      |     ^~
      |     v
game.cpp:75:6: error: 'hv' was not declared in this scope; did you mean 'v'?
   75 |   if(hv.count(scc[i])) return 1;
      |      ^~
      |      v