QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201740#5160. Kebab PizzaVengeful_Spirit#WA 2ms8748kbC++14707b2023-10-05 16:32:142023-10-05 16:32:14

Judging History

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

  • [2023-10-05 16:32:14]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8748kb
  • [2023-10-05 16:32:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int d[N];
vector<int> G[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;
        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: 0ms
memory: 8748kb

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: 2ms
memory: 8328kb

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: 2ms
memory: 8272kb

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: 1ms
memory: 8484kb

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

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

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: 1ms
memory: 8304kb

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'