Submission #743620

#TimeUsernameProblemLanguageResultExecution timeMemory
743620Trisanu_DasKOVANICE (COI15_kovanice)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ff first #define ss second #define int long long int n, m, v; vector<pair<int, int> > edges; vector<int> adj[1000005]; int par[1000005]; void dfs(int u, int p){ if(par[i]) return; par[i] = p; for(int v : adj[u]) dfs(v, u); } vector< int > D[MAXN], R[MAXN]; int d[MAXN], r[MAXN]; int dfs_main(int u, vector< int > *D, int *d) { if (d[i] != 0) return d[i]; for (int j : D[i]) d[i] = max(d[i], dfs_main(j, D, d)); return ++d[i]; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> v; while(v--){ int a, b, char c; cin >> a >> c >> b; if(c == '<') edges.push_back({a, b}); else{ adj[a].push_back(b); adj[b].push_back(a); } } for(int i = 1; i <= m; i++) dfs(i, i); for (auto e : E) { D[com[e.first]].push_back(com[e.second]); R[com[e.second]].push_back(com[e.first]); } for(int i = 1; i < m + 1; i++) dfs_main(par[i], D, d); for(int i = 1; i < m + 1; i++) dfs_main(par[i], R, r); for(int i = 1; i < m + 1; i++){ if(d[par[i]] + r[par[i]] - 1 == n) cout << 'K' << r[par[i]] << '\n'; else cout << "?\n"; } }

Compilation message (stderr)

kovanice.cpp: In function 'void dfs(long long int, long long int)':
kovanice.cpp:15:12: error: 'i' was not declared in this scope
   15 |     if(par[i]) return;
      |            ^
kovanice.cpp:16:9: error: 'i' was not declared in this scope
   16 |     par[i] = p;
      |         ^
kovanice.cpp: At global scope:
kovanice.cpp:20:17: error: 'MAXN' was not declared in this scope
   20 | vector< int > D[MAXN], R[MAXN]; int d[MAXN], r[MAXN];
      |                 ^~~~
kovanice.cpp:20:26: error: 'MAXN' was not declared in this scope
   20 | vector< int > D[MAXN], R[MAXN]; int d[MAXN], r[MAXN];
      |                          ^~~~
kovanice.cpp:20:39: error: 'MAXN' was not declared in this scope
   20 | vector< int > D[MAXN], R[MAXN]; int d[MAXN], r[MAXN];
      |                                       ^~~~
kovanice.cpp:20:48: error: 'MAXN' was not declared in this scope
   20 | vector< int > D[MAXN], R[MAXN]; int d[MAXN], r[MAXN];
      |                                                ^~~~
kovanice.cpp: In function 'long long int dfs_main(long long int, std::vector<long long int>*, long long int*)':
kovanice.cpp:23:9: error: 'i' was not declared in this scope
   23 |   if (d[i] != 0) return d[i];
      |         ^
kovanice.cpp:24:18: error: 'i' was not declared in this scope
   24 |   for (int j : D[i]) d[i] = max(d[i], dfs_main(j, D, d));
      |                  ^
kovanice.cpp:25:14: error: 'i' was not declared in this scope
   25 |   return ++d[i];
      |              ^
kovanice.cpp: In function 'int main()':
kovanice.cpp:32:19: error: expected unqualified-id before 'char'
   32 |         int a, b, char c; cin >> a >> c >> b;
      |                   ^~~~
kovanice.cpp:32:39: error: 'c' was not declared in this scope
   32 |         int a, b, char c; cin >> a >> c >> b;
      |                                       ^
kovanice.cpp:39:19: error: 'E' was not declared in this scope
   39 |     for (auto e : E) {
      |                   ^
kovanice.cpp:40:9: error: 'D' was not declared in this scope
   40 |         D[com[e.first]].push_back(com[e.second]);
      |         ^
kovanice.cpp:40:11: error: 'com' was not declared in this scope; did you mean 'cos'?
   40 |         D[com[e.first]].push_back(com[e.second]);
      |           ^~~
      |           cos
kovanice.cpp:41:9: error: 'R' was not declared in this scope
   41 |         R[com[e.second]].push_back(com[e.first]);
      |         ^
kovanice.cpp:43:53: error: 'D' was not declared in this scope
   43 |     for(int i = 1; i < m + 1; i++) dfs_main(par[i], D, d);
      |                                                     ^
kovanice.cpp:43:56: error: 'd' was not declared in this scope
   43 |     for(int i = 1; i < m + 1; i++) dfs_main(par[i], D, d);
      |                                                        ^
kovanice.cpp:44:53: error: 'R' was not declared in this scope
   44 |     for(int i = 1; i < m + 1; i++) dfs_main(par[i], R, r);
      |                                                     ^
kovanice.cpp:44:56: error: 'r' was not declared in this scope
   44 |     for(int i = 1; i < m + 1; i++) dfs_main(par[i], R, r);
      |                                                        ^
kovanice.cpp:46:12: error: 'd' was not declared in this scope
   46 |         if(d[par[i]] + r[par[i]] - 1 == n) cout << 'K' << r[par[i]] << '\n';
      |            ^
kovanice.cpp:46:24: error: 'r' was not declared in this scope
   46 |         if(d[par[i]] + r[par[i]] - 1 == n) cout << 'K' << r[par[i]] << '\n';
      |                        ^