QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140769#5160. Kebab PizzaRetiredButNotTired#WA 3ms8272kbC++17710b2023-08-16 19:54:322023-08-16 19:54:34

Judging History

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

  • [2023-08-16 19:54:34]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:8272kb
  • [2023-08-16 19:54:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
int tt, tc;

const int N = 1e5 + 9, ALPHA = 331;

set<int> adj[N];

void solve() {

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].insert(v);
        adj[v].insert(u);
    }
    for (int i = 1; i <= k; ++i) {
        int c = 0;
        for (auto v: adj[i])
            c += adj[v].size() > 1 && v != i;
        if (c > 2) return void(cout << "impossible" << endl);
    }
    cout << "possible" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    tt = 1, tc = 1; //cin >> tt;
    while (tt--) solve(), tc++;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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

input:

4 4
1 2
2 1
3 4
4 3

output:

possible

result:

ok single line: 'possible'

Test #6:

score: 0
Accepted
time: 1ms
memory: 8064kb

input:

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

output:

possible

result:

ok single line: 'possible'

Test #7:

score: 0
Accepted
time: 3ms
memory: 8272kb

input:

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

output:

impossible

result:

ok single line: 'impossible'

Test #8:

score: -100
Wrong Answer
time: 3ms
memory: 8152kb

input:

4 5
1 2
3 4
4 5
5 3

output:

possible

result:

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