# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704910 |
2023-03-03T06:41:18 Z |
guagua0407 |
Naboj (COCI22_naboj) |
C++17 |
|
123 ms |
19376 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,m;
cin>>n>>m;
vector<int> in(n,0);
vector<bool> visited(n,false);
vector<int> adj[n],adjr[n];
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
a--;
b--;
in[a]++;
adj[b].push_back(a);
}
queue<int> q;
for(int i=0;i<n;i++){
if(in[i]==0) q.push(i);
}
vector<pair<int,int>> ans;
while(!q.empty()){
int v=q.front();
q.pop();
visited[v]=true;
ans.push_back({v,0});
for(auto u:adj[v]){
if(visited[u]){
cout<<-1;
return 0;
}
in[u]--;
if(in[u]==0){
q.push(u);
}
}
}
reverse(all(ans));
for(auto v:ans){
cout<<v.f+1<<' '<<v.s<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer parameter [name=c] equals to 0, violates the range [1, 9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
123 ms |
19376 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 |
Incorrect |
0 ms |
212 KB |
Integer parameter [name=c] equals to 0, violates the range [1, 9] |
2 |
Halted |
0 ms |
0 KB |
- |