QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211809 | #5522. F*** 3-Colorable Graphs | pengpeng_fudan# | WA | 1ms | 4116kb | C++14 | 1.4kb | 2023-10-12 21:26:01 | 2023-10-12 21:26:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
vector<pair<int,int>> ve[20010];
bool flag[200010];
int dep[20010];
void dfs(int u,int v){
dep[u]=dep[v]+1;
for(auto i:ve[u]){
if(dep[i.first]) continue;
flag[i.second]=1;
dfs(i.first,u);
}
}
void solve() {
int n,m;
cin>>n>>m;
int u,v;
for(int i=1;i<=m;i++){
cin>>u>>v;
ve[u].push_back({v,i});
ve[v].push_back({u,i});
}
dfs(1,1);
vector<int> vk;
for(int i=1;i<=2*n;i++){
vk.clear();
for(auto j:ve[i]){
if(!flag[j.second]){
vk.push_back(j.first);
if(abs(dep[j.second]-dep[j.first])+1==4){
cout<<2<<'\n';
return ;
}
vk.push_back(j.first);
}
}
sort(vk.begin(),vk.end(),[&](int a,int b){return dep[a]<dep[b];});
int sz=vk.size();
for(int i=0;i<sz-1;i++){
if(dep[vk[i+1]]-dep[vk[i]]+2==4){
cout<<2<<'\n';
return ;
}
}
//if(i==5) for(auto j:vk) cout<<j<<' ';
cout<<'\n';
}
cout<<3<<'\n';
return ;
}
int main() {
ios::sync_with_stdio(0),cin.tie(0);
int _ = 1;
//cin >> _;
while(_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4116kb
input:
2 4 1 3 1 4 2 3 2 4
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'