QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201919#5160. Kebab PizzaDreamOn#WA 1ms3728kbC++231.0kb2023-10-05 17:40:032023-10-05 17:40:03

Judging History

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

  • [2023-10-05 17:40:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2023-10-05 17:40:03]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define Maxn 100005

using namespace std;

int n, m, deg[Maxn], vis[Maxn];

struct Edge {
    int next, to;
}
edge[Maxn * 2];
int head[Maxn], edge_num;

void add_edge(int from, int to) {
    edge[++edge_num].next = head[from];
    edge[edge_num].to = to;
    head[from] = edge_num;
}

int main() {
    scanf("%d%d", &m, &n);
    int u, v;
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d", &u, &v);
        if(u == v) continue;
        add_edge(u, v); add_edge(v, u);
        ++deg[u]; ++deg[v];
    }
    for(int i = 1; i <= n; ++i) {
        if(deg[i] == 1) {
            int v = edge[head[i]].to;
            vis[i] = vis[v] = 1;
        }
    }
    for(int i = 1; i <= n; ++i) {
        if(vis[i]) --deg[i];
    }
    bool flag = 1;
    for(int i = 1; i <= n; ++i) {
        if(deg[i] > 2) flag = 0;
    }
    if(flag) cout << "possible" << endl;
    else cout << "impossible" << endl;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3692kb

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

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

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

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

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

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

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'