# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783747 | 2023-07-15T09:42:34 Z | christinelynn | Naboj (COCI22_naboj) | C++17 | 445 ms | 18500 KB |
#include<bits/stdc++.h> #define ll long long #define fi first #define sec second #define pb push_back #define pqueue priority_queue #define int long long #define pii pair<int,int> #define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); using namespace std; int tc,ans=0,n,m; int in1,in2; vector<int> adj[200005]; bool vis[200005]; int point[200005]; vector<int> topo; void dfs(int x){ if(vis[x]) return; vis[x]=1; topo.pb(x); for(auto i : adj[x]){ point[i]--; if(point[i]==0){ dfs(i); } } } main(){ supercepat; cin>>n>>m; for(int i=1;i<=m;i++){ cin>>in1>>in2; adj[in2].pb(in1); point[in1]++; } for(int i=1;i<=n;i++){ if(point[i]==0&&!vis[i]){ dfs(i); } } if(topo.size()!=n){ cout<<-1<<endl; } else{ cout<<topo.size()<<endl; for(auto i : topo){ cout<<i<<" "<<1<<endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4948 KB | Output is correct |
3 | Correct | 3 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 | 3 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 2 ms | 4948 KB | Output is correct |
11 | Correct | 2 ms | 4948 KB | Output is correct |
12 | Correct | 2 ms | 4948 KB | Output is correct |
13 | Correct | 2 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 338 ms | 14636 KB | Output is correct |
2 | Correct | 274 ms | 14612 KB | Output is correct |
3 | Correct | 142 ms | 10024 KB | Output is correct |
4 | Correct | 288 ms | 14532 KB | Output is correct |
5 | Correct | 288 ms | 14700 KB | Output is correct |
6 | Correct | 288 ms | 14520 KB | Output is correct |
7 | Correct | 285 ms | 14528 KB | Output is correct |
8 | Correct | 234 ms | 12488 KB | Output is correct |
9 | Correct | 283 ms | 14544 KB | Output is correct |
10 | Correct | 294 ms | 14584 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4948 KB | Output is correct |
3 | Correct | 3 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 | 3 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 2 ms | 4948 KB | Output is correct |
11 | Correct | 2 ms | 4948 KB | Output is correct |
12 | Correct | 2 ms | 4948 KB | Output is correct |
13 | Correct | 2 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 338 ms | 14636 KB | Output is correct |
16 | Correct | 274 ms | 14612 KB | Output is correct |
17 | Correct | 142 ms | 10024 KB | Output is correct |
18 | Correct | 288 ms | 14532 KB | Output is correct |
19 | Correct | 288 ms | 14700 KB | Output is correct |
20 | Correct | 288 ms | 14520 KB | Output is correct |
21 | Correct | 285 ms | 14528 KB | Output is correct |
22 | Correct | 234 ms | 12488 KB | Output is correct |
23 | Correct | 283 ms | 14544 KB | Output is correct |
24 | Correct | 294 ms | 14584 KB | Output is correct |
25 | Correct | 82 ms | 12928 KB | Output is correct |
26 | Correct | 75 ms | 13608 KB | Output is correct |
27 | Correct | 111 ms | 13932 KB | Output is correct |
28 | Correct | 124 ms | 15180 KB | Output is correct |
29 | Correct | 71 ms | 14020 KB | Output is correct |
30 | Correct | 168 ms | 15068 KB | Output is correct |
31 | Correct | 18 ms | 6484 KB | Output is correct |
32 | Correct | 284 ms | 16448 KB | Output is correct |
33 | Correct | 414 ms | 18040 KB | Output is correct |
34 | Correct | 337 ms | 16444 KB | Output is correct |
35 | Correct | 410 ms | 18072 KB | Output is correct |
36 | Correct | 296 ms | 16364 KB | Output is correct |
37 | Correct | 400 ms | 17500 KB | Output is correct |
38 | Correct | 378 ms | 16920 KB | Output is correct |
39 | Correct | 420 ms | 18076 KB | Output is correct |
40 | Correct | 329 ms | 17316 KB | Output is correct |
41 | Correct | 365 ms | 17232 KB | Output is correct |
42 | Correct | 423 ms | 18388 KB | Output is correct |
43 | Correct | 339 ms | 16504 KB | Output is correct |
44 | Correct | 445 ms | 18500 KB | Output is correct |
45 | Correct | 313 ms | 16424 KB | Output is correct |
46 | Correct | 344 ms | 17272 KB | Output is correct |