10292 | 2024-03-30 10:39:50 | 111 | Pletykálkodás | cpp17 | Wrong answer 0/100 | 71ms | 8264 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<vector<int>>g(N+1);
vector<pair<int,int>>e;
for(int i=0;i<M;i++){
int a,b;
cin>>a>>b;
g[a].push_back(b);
g[b].push_back(a);
e.emplace_back(a,b);
}
vector<tuple<int,int,int,int>>c;
for(int i=1;i<=N;i++){
vector<int>v(N+1);
v[i]=-1;
for(int j:g[i]){
v[j]=-1;
}
for(int j:g[i]){
for(int k:g[j]){
if(v[k]<0){
continue;
}
if(v[k]>0){
c.emplace_back(i,k,j,v[k]);
continue;
}
v[k]=j;
}
}
}
for(auto[a,b,aa,bb]:c){
vector<int>v(N+1,-1);
vector<vector<pair<int,int>>>w(2);
auto dfs=[&](auto self,int i)->void{
for(int j:g[i]){
if(v[j]!=-1){
continue;
}
v[j]=v[i];
self(self,j);
w[v[i]].emplace_back(i,j);
}
};
v[a]=0;
v[b]=1;
v[aa]=0;
v[bb]=1;
dfs(dfs,aa);
dfs(dfs,bb);
if(count(v.begin(),v.end(),-1)==1){
vector<pair<int,int>>s;
for(auto[a,b]:w[0]){
s.emplace_back(a,b);
}
for(auto[a,b]:w[1]){
s.emplace_back(a,b);
}
s.emplace_back(a,aa);
s.emplace_back(b,bb);
s.emplace_back(a,b);
s.emplace_back(aa,bb);
reverse(w[0].begin(),w[0].end());
reverse(w[1].begin(),w[1].end());
for(auto[a,b]:w[0]){
s.emplace_back(a,b);
}
for(auto[a,b]:w[1]){
s.emplace_back(a,b);
}
cout<<s.size()<<'\n';
for(auto[a,b]:s){
cout<<a<<' '<<b<<'\n';
}
return 0;
}
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1828 KiB | ||||
2 | Wrong answer | 3ms | 2052 KiB | ||||
3 | Wrong answer | 4ms | 2484 KiB | ||||
subtask2 | 0/9 | ||||||
4 | Wrong answer | 3ms | 2276 KiB | ||||
5 | Wrong answer | 3ms | 2444 KiB | ||||
6 | Wrong answer | 2ms | 2528 KiB | ||||
subtask3 | 0/13 | ||||||
7 | Wrong answer | 14ms | 3732 KiB | ||||
8 | Wrong answer | 20ms | 3840 KiB | ||||
9 | Wrong answer | 20ms | 3956 KiB | ||||
subtask4 | 0/16 | ||||||
10 | Wrong answer | 18ms | 4792 KiB | ||||
11 | Wrong answer | 18ms | 4880 KiB | ||||
12 | Wrong answer | 17ms | 4768 KiB | ||||
subtask5 | 0/25 | ||||||
13 | Wrong answer | 3ms | 3240 KiB | ||||
14 | Wrong answer | 3ms | 3452 KiB | ||||
15 | Wrong answer | 3ms | 3388 KiB | ||||
16 | Wrong answer | 3ms | 3384 KiB | ||||
17 | Wrong answer | 3ms | 3376 KiB | ||||
18 | Wrong answer | 3ms | 3584 KiB | ||||
19 | Wrong answer | 3ms | 3604 KiB | ||||
subtask6 | 0/13 | ||||||
20 | Wrong answer | 4ms | 4144 KiB | ||||
21 | Wrong answer | 8ms | 4092 KiB | ||||
22 | Wrong answer | 4ms | 4252 KiB | ||||
23 | Wrong answer | 8ms | 4372 KiB | ||||
24 | Wrong answer | 6ms | 4224 KiB | ||||
25 | Wrong answer | 6ms | 4280 KiB | ||||
26 | Wrong answer | 7ms | 4688 KiB | ||||
subtask7 | 0/24 | ||||||
27 | Wrong answer | 26ms | 8252 KiB | ||||
28 | Wrong answer | 35ms | 8244 KiB | ||||
29 | Wrong answer | 26ms | 8264 KiB | ||||
30 | Wrong answer | 37ms | 6372 KiB | ||||
31 | Wrong answer | 43ms | 5784 KiB | ||||
32 | Wrong answer | 50ms | 5392 KiB | ||||
33 | Wrong answer | 59ms | 5348 KiB | ||||
34 | Wrong answer | 71ms | 5204 KiB | ||||
35 | Wrong answer | 46ms | 7036 KiB | ||||
36 | Wrong answer | 52ms | 6620 KiB | ||||
37 | Wrong answer | 61ms | 6708 KiB |