QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75290#4996. Icy Itinerarywangzhe_0477WA 3ms21936kbC++171012b2023-02-04 19:34:272023-02-04 19:34:31

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:34:31]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:21936kb
  • [2023-02-04 19:34:27]
  • 提交

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 (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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 21916kb

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: 3ms
memory: 21936kb

input:

5 0

output:

1
2
3
4
5

result:

ok qwq

Test #3:

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

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)