# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
804425 | 2023-08-03T08:39:34 Z | Tunglam07 | Naboj (COCI22_naboj) | C++17 | 232 ms | 10008 KB |
#include <bits/stdc++.h> using namespace std; vector<long long> vec[200005], ans; long long m ,n ,dp[200005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> m >> n; queue<long long> q; while(n--); { long long a ,b; cin >> a >> b; vec[a].push_back(b); dp[b]++; } for(int i=1;i<=m;i++) { if(dp[i]==0) { q.push(i); } } while(!q.empty()) { long long id = q.front(); q.pop(); ans.push_back(id); for(long long nx:vec[id]) { dp[nx]--; if(dp[nx]==0) { q.push(nx); } } } if(ans.size()!=m) { cout << -1; } else { cout << ans.size() <<endl; for(long long nx:ans) { cout << nx << " " << 0 << endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5000 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 232 ms | 10008 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5000 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |