QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201749 | #5160. Kebab Pizza | Vengeful_Spirit# | WA | 4ms | 18340kb | C++14 | 825b | 2023-10-05 16:36:36 | 2023-10-05 16:36:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int d[N];
vector<int> G[N];
map<int, int> mp[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
for(int i = 1, x, y; i <= n; ++i) {
cin >> x >> y;
if(x == y) continue;
if(x > y) swap(x, y);
if(mp[x].count(y)) continue;
mp[x][y] = 1;
G[x].push_back(y);
G[y].push_back(x);
d[x]++, d[y]++;
}
vector<int> lf;
for(int i = 1; i <= n; ++i) if(d[i] == 1) lf.push_back(i);
for(int i :lf) {
for(int y : G[i]) {
d[y]--;
}
}
for(int i = 1; i <= n; ++i) if(d[i] > 2) {
cout << "impossible\n";
return 0;
}
cout << "possible\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 17592kb
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: 3ms
memory: 17844kb
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: 17548kb
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: 17876kb
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: 3ms
memory: 17888kb
input:
4 4 1 2 2 1 3 4 4 3
output:
possible
result:
ok single line: 'possible'
Test #6:
score: 0
Accepted
time: 3ms
memory: 18268kb
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: 18340kb
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'