QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75301#4996. Icy Itinerarywangzhe_0477WA 6ms22352kbC++171.2kb2023-02-04 19:39:492023-02-04 19:39:52

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:39:52]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:22352kb
  • [2023-02-04 19:39:49]
  • 提交

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[0] = 2, lst[1] = 0, lst[2] = 1;
    nxt[2] = 0, nxt[1] = 2, nxt[0] = 1;
    for (int i = 3; i <= n; i++) {
        if (pos == 1) {
            pos = lst[0];
            lst[i] = pos, lst[nxt[pos]] = i;
            nxt[i] = nxt[pos], nxt[pos] = i;
            if (graph[pos][lst[pos]] == graph[pos][nxt[pos]]) pos = 1;
        }
        else 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 22352kb

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

input:

5 0

output:

1
2
3
4
5

result:

ok qwq

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 20396kb

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)