QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224743#5522. F*** 3-Colorable GraphspiaoyunWA 0ms4008kbC++20786b2023-10-23 12:58:542023-10-23 12:58:55

Judging History

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

  • [2023-10-23 12:58:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4008kb
  • [2023-10-23 12:58:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define otto auto
const int MAXN=1e6+10;
const int INF=1ll*1e7*1e9;
int T,N,M,K,P,Q;
int a[MAXN];
int fa[MAXN];

int getfa(int x){
	if(fa[x] == x) return x;
	return fa[x] = getfa(fa[x]);
}

bool merge(int x,int y){
	x = getfa(x);
	y = getfa(y);
	if(x == y) return false;
	fa[y] = x;
	return true;
}

void prepare(){
	scanf("%lld %lld",&N,&M);
	for(int i = 1;i <= 2*N; i++){
		fa[i] = i;
	}
	for(int i = 1;i <= M; i++){
		int x,y;
		scanf("%lld %lld",&x,&y);
		if(!merge(x,y)){
			printf("2\n");
			return;
		}
	}
	printf("3\n");
}

signed main(){
	//ios::sync_with_stdio(0);
	T=1;
	//scanf("%lld",&T);
	while(T--){
	    prepare();
	}
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3732kb

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

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
Wrong Answer
time: 0ms
memory: 4008kb

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:

2

result:

wrong answer 1st numbers differ - expected: '3', found: '2'