QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75294#4996. Icy Itinerarywangzhe_0477WA 4ms21152kbC++171.0kb2023-02-04 19:36:382023-02-04 19:36:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 19:36:41]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:21152kb
  • [2023-02-04 19:36:38]
  • 提交

answer

#include <bits/stdc++.h>

const int max_n = 3e5 + 5;

int n, m, nxt[max_n], lst[max_n];
std::unordered_map<int, bool> graph[max_n];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        graph[x][y] = true;
        graph[y][x] = true;
    }
    int pos = 2;
    lst[1] = 0, lst[2] = 1;
    nxt[1] = 2, nxt[0] = 1;
    for (int i = 3; i <= n; i++) {
        if (pos == 1 || graph[pos][i] == graph[pos][lst[pos]]) {
            lst[i] = pos, lst[nxt[pos]] = i;
            nxt[i] = nxt[pos], nxt[pos] = i;
            if (nxt[i] && graph[i][lst[i]] == graph[i][nxt[i]]) pos = i;
            else pos = i;
        }
        else {
            nxt[i] = pos, nxt[lst[pos]] = i;
            lst[i] = lst[pos], lst[pos] = i;
            if (lst[i] && graph[i][lst[i]] == graph[i][nxt[i]]) pos = lst[i];
            else pos = i;
        }
    }
    for (int i = nxt[0]; i; i = nxt[i]) printf("%d\n", i);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 20292kb

input:

4 4
1 2
1 3
1 4
3 4

output:

1
3
4
2

result:

ok qwq

Test #2:

score: 0
Accepted
time: 4ms
memory: 21152kb

input:

5 0

output:

1
2
3
4
5

result:

ok qwq

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 20416kb

input:

10 10
7 8
7 5
5 2
6 1
10 7
4 6
5 8
3 2
10 5
1 10

output:

1
3
4
5
6
8
9
10
7
2

result:

wrong answer Changed color too many times (2)