Submission #852268

#TimeUsernameProblemLanguageResultExecution timeMemory
852268Trisanu_DasNaboj (COCI22_naboj)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n, m; cin >> n >> m; int deg[n + 1], u, v; memset(deg, 0, sizeof(deg)); vector<int> adj[n + 1]; while(m--){ cin >> v >> u; adj[u].push_back(u); deg[u]++; } vector<int> toposort; queue<int> q; for(int i = 1; i < n + 1; i++) if(deg[i] == 0) q.push(i); while(!q.empty()){ int u = q.front(); q.pop(; toposort.push_back(u); for(int v : adj[u]){ deg[v]--; if(deg[v] == 0) q.push_back(v); } } if(toposort.size() != n) cout << -1 << '\n'; else{ cout << n << '\n'; for(auto u : toposort) cout << u << ' ' << 0 << '\n'; } }

Compilation message (stderr)

naboj.cpp: In function 'int main()':
naboj.cpp:16:30: error: expected primary-expression before ';' token
   16 |     int u = q.front(); q.pop(;
      |                              ^
naboj.cpp:19:35: error: 'class std::queue<int>' has no member named 'push_back'
   19 |       deg[v]--; if(deg[v] == 0) q.push_back(v);
      |                                   ^~~~~~~~~
naboj.cpp:22:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   if(toposort.size() != n) cout << -1 << '\n';
      |      ~~~~~~~~~~~~~~~~^~~~