# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782210 | 2023-07-13T16:24:05 Z | christinelynn | Naboj (COCI22_naboj) | C++17 | 324 ms | 16308 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,m; vector <ll> al[200005]; ll deg[200005]; int main(){ cin>>n>>m; queue<ll> q; for (int i=1;i<=m;i++){ ll a,b; cin>>a>>b; al[b].push_back(a); deg[a]++; } vector <pair<ll,ll>> ans; for (int i=1;i<=n;i++){ if (deg[i]==0) { q.push(i); ans.push_back({i,0}); } } while(!q.empty()){ ll u=q.front(); q.pop(); for (auto z:al[u]){ deg[z]--; if (deg[z]==0){ ans.push_back({z,0}); q.push(z); } } } if (ans.size()!=n) cout<<-1; else{ for (auto z:ans){ cout<<z.first<<" "<<z.second<<endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 2 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 2 ms | 4948 KB | Output is correct |
8 | Incorrect | 3 ms | 4948 KB | Integer parameter [name=c] equals to 0, violates the range [1, 10] |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 324 ms | 16308 KB | Integer parameter [name=c] equals to 0, violates the range [1, 200000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 2 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 2 ms | 4948 KB | Output is correct |
8 | Incorrect | 3 ms | 4948 KB | Integer parameter [name=c] equals to 0, violates the range [1, 10] |
9 | Halted | 0 ms | 0 KB | - |