QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#374505 | #4686. Tours | eastcloud | WA | 2ms | 4948kb | C++14 | 1.5kb | 2024-04-02 14:48:48 | 2024-04-02 14:48:49 |
Judging History
answer
#include<bits/stdc++.h>
#define ll unsigned long long
#define N 20005
using namespace std;
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(ll x){
if(x<0)x=-x,putchar('-');
if(x/10)write(x/10);
putchar(x%10+'0');
}
vector<ll> e[N],son[N];
mt19937_64 myrand(20080623);
ll dep[N],val[N],f[N];
vector<ll> buc;
void dfs(ll x,ll fa){
f[x]=fa;dep[x]=dep[fa]+1;
for(auto v:e[x]){
if(v==fa)continue;
if(!dep[v])dfs(v,x),son[x].push_back(v);
else if(dep[v]<dep[x]){
ll has=myrand();val[x]^=has;val[v]^=has;buc.push_back(has);
}
}
for(auto v:son[x])val[x]^=val[v];
if(x!=1)buc.push_back(val[x]);
}
ll gcd(ll x,ll y){
if(!y)return x;
else return gcd(y,x%y);
}
int main(){
#ifdef EAST_CLOUD
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
ll n=read(),m=read();
for(ll i=1;i<=m;i++){
ll u=read(),v=read();
e[u].push_back(v);e[v].push_back(u);
}
dfs(1,0);
sort(buc.begin(),buc.end());ll ans=20080623,cnt=1;
for(ll i=1;i<buc.size();i++){
if(buc[i]==buc[i-1])cnt++;
else{
if(ans==20080623)ans=cnt;
else ans=gcd(ans,cnt);cnt=1;
}
}
if(cnt)ans=gcd(ans,cnt);
for(ll i=1;i<=ans;i++)if(ans%i==0)write(i),putchar(' ');
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4496kb
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: 1ms
memory: 4620kb
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: 1ms
memory: 4552kb
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: 1ms
memory: 4520kb
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: 1ms
memory: 4564kb
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: 1ms
memory: 4512kb
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: 0
Accepted
time: 1ms
memory: 4552kb
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 3
result:
ok 2 number(s): "1 3"
Test #8:
score: 0
Accepted
time: 1ms
memory: 4612kb
input:
33 35 10 13 6 13 9 19 5 15 29 31 2 3 4 16 3 20 7 13 31 32 12 24 2 22 17 23 26 27 17 20 16 25 3 12 28 29 1 8 12 18 27 28 14 21 10 19 25 26 5 14 15 16 9 18 4 23 25 30 1 10 8 18 7 24 29 30 6 21 15 22
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: -100
Wrong Answer
time: 2ms
memory: 4948kb
input:
2000 2000 1036 1254 1453 1496 342 1815 186 346 840 1555 138 1503 416 1376 660 1253 1279 1799 209 1554 624 1278 792 884 333 1703 393 894 551 1192 1705 1805 302 930 115 1384 151 1156 71 209 82 1637 858 1854 19 1798 348 703 1692 1744 261 1029 143 1631 336 1227 1493 1564 493 1966 553 1587 953 1128 214 1...
output:
1
result:
wrong answer Answer contains longer sequence [length = 20], but output contains 1 elements