#include <bits/stdc++.h>
using namespace std;
const int mx = 5e5 + 5;
int n, m, pth[mx]; bool vis[mx], useEdg[mx]; vector<pair<int, int>> adj[mx];
void dfs(int cur){
if (vis[cur]){
int cyc = cur;
while (vis[cyc]){
cout<<cyc<<" ";
vis[cyc] = 0; cyc = pth[cyc];
}
cout<<endl;
}
while (adj[cur].size()){
int nxt, ind;
tie(nxt, ind) = adj[cur].back(); adj[cur].pop_back();
if (!useEdg[ind]){
useEdg[ind] = vis[cur] = 1;
pth[cur] = nxt;
dfs(nxt);
}
}
}
int main(){
cin >> n >> m;
for (int i = 1; i <= m; i++){
int a, b; cin >> a >> b;
adj[a].push_back({b, i}); adj[b].push_back({a, i});
}
dfs(1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12040 KB |
Output is correct |
2 |
Correct |
7 ms |
11980 KB |
Output is correct |
3 |
Correct |
7 ms |
12040 KB |
Output is correct |
4 |
Correct |
11 ms |
12236 KB |
Output is correct |
5 |
Correct |
7 ms |
12052 KB |
Output is correct |
6 |
Correct |
9 ms |
12444 KB |
Output is correct |
7 |
Correct |
20 ms |
13324 KB |
Output is correct |
8 |
Correct |
11 ms |
12236 KB |
Output is correct |
9 |
Correct |
69 ms |
19824 KB |
Output is correct |
10 |
Correct |
12 ms |
12204 KB |
Output is correct |
11 |
Correct |
9 ms |
12236 KB |
Output is correct |
12 |
Correct |
100 ms |
20360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
11980 KB |
Output is correct |
2 |
Correct |
6 ms |
11980 KB |
Output is correct |
3 |
Correct |
6 ms |
11980 KB |
Output is correct |
4 |
Correct |
9 ms |
12236 KB |
Output is correct |
5 |
Correct |
7 ms |
12108 KB |
Output is correct |
6 |
Correct |
9 ms |
12364 KB |
Output is correct |
7 |
Correct |
16 ms |
13332 KB |
Output is correct |
8 |
Correct |
10 ms |
12236 KB |
Output is correct |
9 |
Correct |
67 ms |
19852 KB |
Output is correct |
10 |
Correct |
10 ms |
12236 KB |
Output is correct |
11 |
Correct |
9 ms |
12184 KB |
Output is correct |
12 |
Correct |
76 ms |
20280 KB |
Output is correct |
13 |
Correct |
96 ms |
22100 KB |
Output is correct |
14 |
Correct |
113 ms |
19396 KB |
Output is correct |
15 |
Correct |
117 ms |
21144 KB |
Output is correct |
16 |
Correct |
100 ms |
22084 KB |
Output is correct |
17 |
Correct |
120 ms |
17352 KB |
Output is correct |
18 |
Correct |
123 ms |
20580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
8 ms |
12044 KB |
Output is correct |
3 |
Correct |
7 ms |
11980 KB |
Output is correct |
4 |
Correct |
10 ms |
12236 KB |
Output is correct |
5 |
Correct |
7 ms |
12108 KB |
Output is correct |
6 |
Correct |
9 ms |
12364 KB |
Output is correct |
7 |
Correct |
16 ms |
13296 KB |
Output is correct |
8 |
Correct |
8 ms |
12236 KB |
Output is correct |
9 |
Correct |
64 ms |
19956 KB |
Output is correct |
10 |
Correct |
10 ms |
12236 KB |
Output is correct |
11 |
Correct |
8 ms |
12184 KB |
Output is correct |
12 |
Correct |
76 ms |
20492 KB |
Output is correct |
13 |
Correct |
94 ms |
22148 KB |
Output is correct |
14 |
Correct |
146 ms |
19400 KB |
Output is correct |
15 |
Correct |
116 ms |
21044 KB |
Output is correct |
16 |
Correct |
125 ms |
22176 KB |
Output is correct |
17 |
Correct |
131 ms |
17268 KB |
Output is correct |
18 |
Correct |
121 ms |
20736 KB |
Output is correct |
19 |
Execution timed out |
573 ms |
63988 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |