# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
781964 | 2023-07-13T14:13:05 Z | devariaota | Naboj (COCI22_naboj) | C++17 | 422 ms | 18908 KB |
#include<bits/stdc++.h> using namespace std; #define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pii pair<int, int> #define fi first #define se second #define pb push_back int n, m; vector<int> adj[200004]; bool vis[200004]; vector<int> st; void topsort(int u) { if(vis[u]) return; vis[u] = 1; for(auto v : adj[u]) { if(!vis[v]) topsort(v); } st.push_back(u); } int main() { ioss; cin >> n >> m; set<int> tmp; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; tmp.insert(a); adj[b].pb(a); } if(tmp.size() == n) { cout << -1 << endl; return 0; } for(int i = 1; i <= n; i++) { if(!vis[i]) topsort(i); } cout << st.size() << endl; while(!st.empty()) { int u = st.back(); st.pop_back(); if(tmp.count(u)) cout << u << " " << 1 << endl; else cout << u << " " << 0 << endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 392 ms | 18904 KB | Output is correct |
2 | Correct | 384 ms | 18884 KB | Output is correct |
3 | Correct | 167 ms | 12588 KB | Output is correct |
4 | Correct | 369 ms | 18888 KB | Output is correct |
5 | Correct | 361 ms | 18848 KB | Output is correct |
6 | Correct | 422 ms | 18840 KB | Output is correct |
7 | Correct | 384 ms | 18888 KB | Output is correct |
8 | Correct | 271 ms | 15984 KB | Output is correct |
9 | Correct | 411 ms | 18908 KB | Output is correct |
10 | Correct | 390 ms | 18884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |