# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
847092 | 2023-09-09T06:48:06 Z | Pacybwoah | Naboj (COCI22_naboj) | C++17 | 156 ms | 15288 KB |
#include<iostream> #include<vector> #include<queue> #include<utility> #include<algorithm> using namespace std; int main(){ int n,m; cin>>n>>m; vector<int> deg(n+1); vector<vector<int> > graph(n+1); int a,b; for(int i=0;i<m;i++){ cin>>a>>b; deg[b]++; graph[a].push_back(b); } vector<int> topo; queue<int> q; for(int i=1;i<=n;i++) if(deg[i]==0) q.push(i); while(!q.empty()){ int node=q.front(); q.pop(); topo.push_back(node); for(auto x:graph[node]){ deg[x]--; if(deg[x]==0) q.push(x); } } if(topo.size()!=n) cout<<-1; else for(auto x:topo) cout<<x<<' '<<0<<"\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 436 KB | Output is correct |
5 | Correct | 0 ms | 436 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 436 KB | Output is correct |
8 | Incorrect | 0 ms | 432 KB | Integer parameter [name=c] equals to 0, violates the range [1, 10] |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 156 ms | 15288 KB | Integer parameter [name=c] equals to 0, violates the range [1, 200000] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 436 KB | Output is correct |
5 | Correct | 0 ms | 436 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 436 KB | Output is correct |
8 | Incorrect | 0 ms | 432 KB | Integer parameter [name=c] equals to 0, violates the range [1, 10] |
9 | Halted | 0 ms | 0 KB | - |