QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211811 | #5522. F*** 3-Colorable Graphs | pengpeng_fudan# | WA | 33ms | 10584kb | C++14 | 1.4kb | 2023-10-12 21:28:02 | 2023-10-12 21:28:02 |
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.first]-dep[i])+1==4){
cout<<2<<'\n';
return ;
}
}
}
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4068kb
input:
2 4 1 3 1 4 2 3 2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
3 5 1 4 2 4 2 5 3 5 3 6
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 5ms
memory: 4992kb
input:
10000 20000 4570 11730 8803 16440 4257 15381 4455 17636 5256 13543 2172 18421 7735 17847 8537 16010 6175 12263 1079 13410 335 15901 3272 16233 7435 11454 4469 13374 1564 13416 1264 13446 7484 14510 8193 12267 628 15585 1388 11398 5444 19958 2059 18140 8947 13188 6214 17707 7940 12253 6726 11508 1839...
output:
...
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 33ms
memory: 10324kb
input:
9999 199986 8408 17344 1353 16706 3364 17274 9410 10006 9387 19375 9169 18239 3930 12759 4728 11328 5192 17935 7616 19485 3138 12714 8595 18490 6020 15039 9319 17097 7842 16814 7644 18723 2190 10117 3971 13350 232 15408 6984 12842 6988 17196 9744 18905 6759 13371 4115 18937 1842 13513 6245 18736 207...
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: -100
Wrong Answer
time: 28ms
memory: 10584kb
input:
9999 199986 1284 14140 5071 12232 7015 15577 4211 14089 3764 14645 4634 19044 1944 18455 5249 19603 1607 10182 9986 19929 1132 18778 3848 10147 636 10961 1994 14118 5084 18986 4067 19483 2288 17337 3108 15530 2258 12709 9809 14997 4860 11548 1779 13012 5062 16123 7418 10293 7726 11733 1145 14062 369...
output:
2
result:
wrong answer 1st numbers differ - expected: '3', found: '2'