QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211646#5522. F*** 3-Colorable Graphspengpeng_fudan#RE 1ms3912kbC++141.2kb2023-10-12 19:52:512023-10-12 19:52:51

Judging History

你现在查看的是最新测评结果

  • [2023-10-12 19:52:51]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3912kb
  • [2023-10-12 19:52:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
vector<int> ve[10010];
int du[10010];
bool flag[10010];
int dep[10010];
int cnt=0;
int mn_cir=6;
void dfs(int u,int v){
    dep[u]=++cnt;
    //cout<<u<<' '<<dep[u]<<'\n';
    for(auto i:ve[u]){
        if(i==v)    continue;
        else if(dep[i]){
            if(dep[i]<dep[u])   mn_cir=min(mn_cir,dep[u]-dep[i]+1);
        }
        else dfs(i,u);
    }
}
void solve() {
    int n,m;
    cin>>n>>m;
    n=n*2;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        ve[u].push_back(v);
        ve[v].push_back(u);
        du[u]++;
        du[v]++;
    }
    int ans=4;
    for(int i=1;i<=n;i++){
        if(du[i]>=3)    ans=3;    
    }
    for(int i=1;i<=n;i++){
        if(!dep[i]){
            cnt=0;
            dfs(i,i);
        }    
    }
    for(int i=1;i<=n;i++){
        //cout<<dep[i]<<'\n';
        if(dep[i]>=3)   ans=3;
    }
    if(mn_cir==4)  ans=2;
    cout<<ans<<'\n';
}
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: 3912kb

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: 3908kb

input:

3 5
1 4
2 4
2 5
3 5
3 6

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: -100
Runtime Error

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: