QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61191 | #3067. Justified Jungle | chiranko# | WA | 3ms | 26920kb | C++14 | 841b | 2022-11-11 13:45:30 | 2022-11-11 13:45:32 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 5;
vector<int> E[maxn];
int fl, n;
int dfs(int x, int fr, int y)
{
int res = 1;
for(auto &v : E[x]){
if(v == fr)
continue;
res += dfs(v, x, y);
}
// cout << x << " " << fr << " " << y << " " << res << endl;
if(res <= y)
return res % y;
else{
fl = 1;
return 0;
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i < n; ++i){
int a, b;
cin >> a >> b;
E[a].pb(b), E[b].pb(a);
}
vector<int> ans;
for(int i = 1; i <= n; ++i){
if(!(n % (i + 1))){
fl = 1;
dfs(1, 0, n / (i + 1));
ans.pb(i);
}
}
for(int i = 0; i < ans.size(); ++i)
cout << ans[i] << " \n"[i==ans.size()-1];
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 26920kb
input:
8 1 2 2 3 1 4 4 5 6 7 8 3 7 3
output:
1 3 7
result:
ok single line: '1 3 7'
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 26784kb
input:
96 73 27 3 59 32 76 74 17 38 8 93 46 11 23 9 68 73 59 3 32 32 74 74 8 8 93 46 11 11 9 7 71 92 78 29 35 34 51 81 36 65 79 2 58 6 40 7 92 78 35 35 51 34 36 81 65 65 2 2 6 39 21 25 24 77 94 42 75 39 24 24 77 94 75 54 64 63 88 91 67 85 31 64 88 63 67 91 85 42 91 32 7 92 85 47 49 90 14 62 5 89 96 69 50 4...
output:
1 2 3 5 7 11 15 23 31 47 95
result:
wrong answer 1st lines differ - expected: '1 2 5 11 23 47 95', found: '1 2 3 5 7 11 15 23 31 47 95'