QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201683#5160. Kebab Pizzasalvator_noster#WA 0ms3816kbC++17688b2023-10-05 16:06:562023-10-05 16:06:56

Judging History

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

  • [2023-10-05 16:06:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2023-10-05 16:06:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int M=1e5+10;
typedef pair<int,int> pii;
pii piz[M];
int cnt[M],deg[M];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b)swap(a,b);
		piz[i]=make_pair(a,b);
	}
	sort(piz+1,piz+n+1);
	n=unique(piz+1,piz+n+1)-piz-1;
	for(int i=1;i<=n;++i){
		auto [a,b]=piz[i];
		if(a==b)continue;
		cnt[a]++,cnt[b]++;
	}
	for(int i=1;i<=n;++i){
		auto [a,b]=piz[i];
		if(a==b)continue;
		if(cnt[b]>=2)deg[a]++;
		if(cnt[a]>=2)deg[b]++;
	}
	for(int i=1;i<=k;++i){
		if(deg[i]>2){
			puts("impossible");
			return 0;
		}
	}
	puts("possible");
	return 0;
}

详细

Test #1:

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

input:

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

output:

possible

result:

ok single line: 'possible'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

possible

result:

ok single line: 'possible'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

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

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

8 4
1 1
1 2
2 1
2 2
3 3
3 4
4 3
4 4

output:

possible

result:

ok single line: 'possible'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

4 4
1 2
2 1
3 4
4 3

output:

possible

result:

ok single line: 'possible'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

possible

result:

ok single line: 'possible'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3660kb

input:

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

output:

possible

result:

wrong answer 1st lines differ - expected: 'impossible', found: 'possible'