QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#392830#4686. TourssuomynonAWA 0ms3772kbC++201.3kb2024-04-17 21:07:542024-04-17 21:07:55

Judging History

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

  • [2024-04-17 21:07:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-04-17 21:07:54]
  • 提交

answer

#include <bits/stdc++.h>
using u32 = unsigned int;
const int N = 2e3, M = 2e3;
std::mt19937 rnd(19260817);
int n, m;
struct Edge { int x, y; }ed[M + 5];
std::vector<int> v[N + 5];
int fa[N + 5];
bool vis[N + 5];
void dfs1(int x) {
    vis[x] = 1;
    for (auto i : v[x]) if (!vis[i]) fa[i] = x, dfs1(i);
}
u32 val[M + 5], ar[N + 5];
void dfs2(int x) { for (auto i : v[x]) if (fa[i] == x) dfs2(i), ar[x] ^= ar[i]; }
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n >> m;
    for (int i = 1, x, y; i <= m; ++i)
        std::cin >> x >> y, ed[i] = {x, y}, v[x].push_back(y), v[y].push_back(x);
    dfs1(1);
    for (int i = 1; i <= m; ++i) {
        if (fa[ed[i].x] == fa[ed[i].y]) std::swap(ed[i].x, ed[i].y);
        if (fa[ed[i].y] != ed[i].x) val[i] = rnd(), ar[ed[i].x] ^= val[i], ar[ed[i].y] ^= val[i];
    }
    dfs2(1);
    for (int i = 1; i <= m; ++i) if (fa[ed[i].y] == ed[i].x) val[i] = ar[ed[i].y];
    std::sort(val + 1, val + 1 + n);
    int ans = 0;
    for (int i = 1, cnt = 0; i <= m; ++i) {
        ++cnt;
        if (val[i] != val[i + 1]) {
            if (val[i]) ans = std::__gcd(ans, cnt);
            cnt = 0;
        }
    }
    for (int i = 1; i <= ans; ++i) if (ans % i == 0) std::cout << i << " ";
    std::cout << "\n";
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

1 

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

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

output:

1 3 

result:

ok 2 number(s): "1 3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

1 

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

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

output:

1 3 

result:

ok 2 number(s): "1 3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

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

output:

1 2 

result:

ok 2 number(s): "1 2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

6 7
1 2
2 3
3 4
4 5
5 6
1 6
3 6

output:

1 

result:

ok 1 number(s): "1"

Test #7:

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

input:

33 36
2 22
12 18
27 28
9 19
26 27
6 21
15 16
2 3
7 24
3 12
4 23
28 29
5 14
29 30
1 10
11 13
6 13
16 25
14 21
4 16
10 19
10 11
5 15
1 8
3 20
7 13
25 26
29 31
17 23
8 18
12 24
25 30
31 32
17 20
15 22
9 18

output:

1 

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements