QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201683 | #5160. Kebab Pizza | salvator_noster# | WA | 0ms | 3816kb | C++17 | 688b | 2023-10-05 16:06:56 | 2023-10-05 16:06:56 |
Judging History
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'