10283 | 2024-03-29 22:46:13 | 111 | Pletykálkodás | cpp17 | Wrong answer 0/100 | 1.582s | 8192 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<pair<int,int>>ans(N*2);
for(auto[a,b]:e){
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];
w[v[i]].emplace_back(i,j);
self(self,j);
}
};
v[a]=0;
v[b]=1;
dfs(dfs,a);
dfs(dfs,b);
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,b);
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);
}
if(s.size()<ans.size()){
ans=s;
}
}
cout<<ans.size()<<'\n';
for(auto[a,b]:ans){
cout<<a<<' '<<b<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2020 KiB | ||||
3 | Wrong answer | 116ms | 2756 KiB | ||||
subtask2 | 0/9 | ||||||
4 | Accepted | 3ms | 2352 KiB | ||||
5 | Wrong answer | 2ms | 2420 KiB | ||||
6 | Wrong answer | 3ms | 2656 KiB | ||||
subtask3 | 0/13 | ||||||
7 | Time limit exceeded | 1.575s | 3452 KiB | ||||
8 | Time limit exceeded | 1.562s | 3608 KiB | ||||
9 | Time limit exceeded | 1.562s | 3840 KiB | ||||
subtask4 | 0/16 | ||||||
10 | Time limit exceeded | 1.562s | 3532 KiB | ||||
11 | Time limit exceeded | 1.577s | 3840 KiB | ||||
12 | Time limit exceeded | 1.582s | 4252 KiB | ||||
subtask5 | 0/25 | ||||||
13 | Wrong answer | 4ms | 4196 KiB | ||||
14 | Wrong answer | 4ms | 4524 KiB | ||||
15 | Wrong answer | 4ms | 4732 KiB | ||||
16 | Wrong answer | 4ms | 4880 KiB | ||||
17 | Wrong answer | 4ms | 4708 KiB | ||||
18 | Wrong answer | 4ms | 4712 KiB | ||||
19 | Wrong answer | 3ms | 4712 KiB | ||||
subtask6 | 0/13 | ||||||
20 | Wrong answer | 230ms | 5720 KiB | ||||
21 | Wrong answer | 218ms | 5628 KiB | ||||
22 | Wrong answer | 228ms | 5696 KiB | ||||
23 | Time limit exceeded | 1.552s | 5268 KiB | ||||
24 | Wrong answer | 578ms | 6520 KiB | ||||
25 | Wrong answer | 303ms | 6284 KiB | ||||
26 | Wrong answer | 218ms | 6204 KiB | ||||
subtask7 | 0/24 | ||||||
27 | Time limit exceeded | 1.542s | 7096 KiB | ||||
28 | Time limit exceeded | 1.57s | 7376 KiB | ||||
29 | Time limit exceeded | 1.562s | 7536 KiB | ||||
30 | Time limit exceeded | 1.569s | 7556 KiB | ||||
31 | Time limit exceeded | 1.57s | 7520 KiB | ||||
32 | Time limit exceeded | 1.557s | 7452 KiB | ||||
33 | Time limit exceeded | 1.56s | 7416 KiB | ||||
34 | Time limit exceeded | 1.58s | 7468 KiB | ||||
35 | Time limit exceeded | 1.57s | 7908 KiB | ||||
36 | Time limit exceeded | 1.582s | 7940 KiB | ||||
37 | Time limit exceeded | 1.575s | 8192 KiB |