QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#329762 | #2210. Hamilton Path | Crysfly | WA | 191ms | 41260kb | C++17 | 4.8kb | 2024-02-17 02:15:11 | 2024-02-17 02:15:11 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,modint b){return a.x==b.x;}
friend bool operator !=(modint a,modint b){return a.x!=b.x;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 1000005
#define inf 0x3f3f3f3f
mt19937_64 rnd(64);
modint pw[maxn];
int n,m;
vi e[maxn];
bool vis[maxn];
int id[maxn],q[maxn],idx;
bool wk(int u){
// cout<<"wk "<<u<<"\n";
For(i,1,n)id[i]=q[i]=0;
q[1]=u,id[u]=1,idx=1;
For(i,2,n){
int t=0;
for(int v:e[u])
if(!id[v]){
if(t!=0 && t!=v)return 0;
t=v;
}
if(t==0)return 0;
u=t;
// cout<<"u: "<<i<<" "<<u<<"\n";
q[i]=u,id[u]=i,idx=i;
}
// cout<<"q: ";For(i,1,n)cout<<q[i]<<" "; cout<<"\n";
return 1;
}
vector<pii> ans;
modint F(){
modint res=0;
For(i,1,n)res=res*10+q[i];
return res;
}
int mn,mn2;
void chain(){
ans.pb(mkp(q[1],F().x));
if(mn==n) return;
int up=0;
For(i,mn+1,mn2){
for(int v:e[q[i]])
if(id[v]<mn){
if(up==0||up==i)up=i;
else up=-1;
}
}
// cout<<"mn,mn2,up "<<mn<<" "<<mn2<<" "<<up<<"\n";
int qn=q[mn+1];
if(up==0){
if(wk(qn)) ans.pb(mkp(q[1],F().x));
}
else if(up!=-1 && up!=0){
// cout<<"up "<<up<<"\n";
// cerr<<"q2: "<<q[up]<<"\n";
int t=q[up+1];
if(wk(t)) ans.pb(mkp(q[1],F().x));
}
}
modint w[maxn];
int c[maxn];
void circ(){
For(i,0,n+1)c[i]=0;
w[1]=F();
For(i,2,n){
w[i]=w[i-1]-pw[n-1]*q[i-1];
w[i]*=10,w[i]+=q[i-1];
}
For(u,1,n){
for(int v:e[u])
if(id[v]<id[u]) {
if(id[v]==1 && id[u]==n) continue;
c[id[v]+1]++,c[id[u]+1]--;
}
}
modint res=0;
For(i,1,n){
c[i]+=c[i-1];
if(!c[i]) ans.pb(mkp(q[i],w[i].x));
}
}
void work(int O)
{
n=read(),m=read();ans.clear();
// if(O==14){
// cout<<n<<" "<<m<<"\n";
// For(i,1,m){
// int u=read(),v=read();
// cout<<u<<" "<<v<<"\n";
// }exit(0);
// }
For(i,1,n)e[i].clear();
int tim=1;
while((1<<tim)<n)tim*=2;
tim*=5;
set<pii>S;
For(i,1,m){
int u=read(),v=read();
if(S.count(mkp(u,v))) continue;
S.insert(mkp(u,v));
e[u].pb(v);
}
bool ok=0;
vi o;
For(i,1,n) o.pb(i);
while(o.size() && (tim--)){
int pos=o[rnd()%o.size()];
if(wk(pos)){
ok=1;
// cout<<"ok "<<pos<<"\n";
break;
}
vi o2;
for(int x:o) if(!id[x]) o2.pb(x);
o=o2;
}
if(!ok){
cout<<0<<"\n";
return;
}
mn=n,mn2=n;
for(int v:e[q[n]]){
if(id[v]<mn)mn2=mn,mn=id[v];
else if(id[v]!=mn && id[v]<mn2)mn2=id[v];
}
if(mn==1 && mn!=n)circ();
else chain();
sort(ans.begin(),ans.end());
cout<<ans.size()<<"\n";
for(auto [x,y]:ans)cout<<y<<' ';cout<<"\n";
}
signed main()
{
pw[0]=1;
For(i,1,1000000)pw[i]=pw[i-1]*10;
int T=read();
For(_,1,T)work(_);
return 0;
}
/*
1
5 12
3 5
2 3
4 5
2 5
5 3
1 4
3 2
2 4
1 4
4 1
2 5
4 5
5 3 2 4 1
1 4 5 3 2
1 3 4 2 5
*/
详细
Test #1:
score: 100
Accepted
time: 10ms
memory: 37596kb
input:
1 5 6 3 4 2 5 5 3 1 3 4 2 5 1
output:
2 13425 34251
result:
ok 3 number(s): "2 13425 34251"
Test #2:
score: 0
Accepted
time: 128ms
memory: 40036kb
input:
67777 9 32 6 3 5 2 7 3 7 8 5 2 5 2 7 8 8 2 7 3 8 9 4 3 2 3 4 3 3 1 1 3 8 3 9 8 3 2 5 6 4 5 9 4 6 7 2 8 5 4 5 3 7 8 5 1 6 9 8 3 6 9 7 8 4 1 5 12 3 5 2 3 4 5 2 5 5 3 1 4 3 2 2 4 1 4 4 1 2 5 4 5 2 10 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 2 10 28 1 9 5 9 6 1 10 5 8 7 1 4 7 10 7 5 6 8 9 4 2 9 6 4 2 6 1 1...
output:
1 132894567 2 14532 53241 2 12 21 1 594731198 1 74123568 2 12 21 1 6241735 1 1 1 513264 1 7241356 2 213 312 1 247381965 1 123 1 31524 2 12 21 1 1 1 12 2 132 231 1 41268753 1 245378846 1 526134 1 413652 1 12345 1 31542 2 12 21 1 5624713 1 4675213 3 202947333 852029431 52029...
result:
ok 148279 numbers
Test #3:
score: 0
Accepted
time: 135ms
memory: 39704kb
input:
90961 2 4 2 1 2 1 2 1 2 1 4 8 4 3 2 1 4 3 1 2 4 1 1 4 1 2 4 2 5 22 1 3 5 2 3 1 3 4 3 4 2 3 2 4 3 2 5 4 5 3 4 3 2 1 1 4 1 2 1 3 2 1 4 5 4 3 1 5 5 3 2 3 4 5 8 22 1 4 3 8 8 6 5 7 5 6 1 3 1 2 8 5 8 3 5 2 6 5 2 5 6 1 6 7 5 4 2 4 4 1 6 3 4 3 8 1 6 5 7 6 10 7 10 8 9 3 10 5 4 6 10 7 10 3 3 1 8 28 7 8 8 5 6 ...
output:
1 21 1 2143 0 0 0 0 1 1 2 12 21 0 0 0 0 2 12 21 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 213 0 0 0 1 1 0 0 0 2 123 231 2 12 21 0 0 1 2413 0 0 0 1 1 1 1 2 12 21 0 0 0 0 1 213 0 0 1 132 0 2 12 21 0 0 1 1 1 1 0 0 0 0 1 21 0 2 12 21 1 34152 0 0 1 1 0 0 1 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 ...
result:
ok 124496 numbers
Test #4:
score: 0
Accepted
time: 129ms
memory: 39164kb
input:
64460 7 24 6 7 1 3 2 1 5 6 7 5 2 5 4 2 3 1 3 4 1 5 7 6 1 7 1 6 7 2 2 7 4 5 4 3 6 5 7 6 3 1 7 5 2 7 1 7 1 2 7 18 6 2 7 5 3 4 4 5 2 1 6 2 7 6 7 6 5 7 7 6 3 2 1 2 7 2 5 2 1 6 5 1 3 6 3 6 2 4 2 1 2 1 1 2 2 1 5 26 5 1 3 1 5 2 1 4 3 5 2 1 3 4 3 5 1 4 3 4 2 1 2 3 1 4 2 1 1 4 2 4 1 2 3 1 5 2 2 1 4 1 3 4 3 1...
output:
1 5672134 0 2 12 21 1 41235 1 15324 2 1764352 7643521 1 1234 1 374219658 1 264531 1 812937456 1 132 1 1 2 12 21 1 6174235 1 134800596 1 273591684 1 321 0 2 12 21 1 625143 1 1 1 213 1 872632014 1 612345 1 65384172 1 193248657 1 786034249 1 85462731 1 231 1 31542 1 57461839...
result:
ok 132329 numbers
Test #5:
score: 0
Accepted
time: 123ms
memory: 39748kb
input:
67484 4 19 1 3 4 3 2 3 2 3 4 3 2 3 3 4 4 1 4 1 2 4 2 3 2 1 4 1 4 1 4 3 4 2 4 1 2 1 3 1 10 23 8 4 6 4 6 5 3 2 10 9 5 4 9 5 7 10 8 1 2 6 5 4 2 9 8 4 6 2 5 7 6 3 2 4 9 4 7 1 10 1 4 8 5 2 1 7 2 10 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 0 8 22 5 4 5 4 6 2 3 2 6 1 8 5 2 3 5 3 7 4 2 6 2 3 5 4 5 6 5 3 1 ...
output:
1 1342 1 818095235 2 12 21 1 1 1 32617485 1 3142 2 12 21 1 3214567 1 218350734 1 824796351 1 5173264 1 1 1 123 1 623918456 2 12 21 1 2613475 1 491303652 1 983561724 1 123 3 652314987 765231498 876523149 1 1 1 68451732 1 34125876 1 1 2 231 312 2 123 312 1 81457263 1 3214 1...
result:
ok 147424 numbers
Test #6:
score: 0
Accepted
time: 133ms
memory: 39236kb
input:
90788 3 3 2 1 2 3 1 3 5 18 3 2 5 4 4 3 4 3 5 3 3 5 3 4 2 1 2 1 3 2 5 3 4 5 3 5 1 5 3 2 5 2 1 4 2 5 7 4 1 2 5 1 6 7 7 6 8 11 5 4 7 8 4 6 2 3 6 3 2 5 2 6 3 1 7 4 4 7 6 3 8 2 6 8 1 4 5 4 2 5 2 4 1 4 1 3 10 18 5 6 8 5 9 4 4 1 4 8 4 9 6 5 10 8 2 7 2 3 5 10 4 10 8 4 2 1 2 8 2 4 2 3 5 8 8 17 4 6 4 1 2 5 8 ...
output:
0 0 0 0 0 0 0 0 0 0 1 21 0 0 0 0 1 1 0 0 1 213 0 2 12 21 0 0 0 0 1 1432 0 0 0 2 213 321 0 0 0 2 12 21 0 2 12 21 0 0 1 52143 2 12 21 0 2 12 21 1 321 1 1 1 1 0 0 0 0 0 0 1 1 1 321 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 321 0 2 12 21 2 12 21 0 0 0 1 321456 0 1 132 1 213 2 12 21 0 0 0 0...
result:
ok 124312 numbers
Test #7:
score: 0
Accepted
time: 120ms
memory: 37612kb
input:
64767 2 2 1 2 1 2 6 22 4 6 4 2 2 6 1 2 2 6 1 3 5 2 5 3 5 6 1 4 2 1 4 2 2 6 6 3 3 6 5 3 6 3 2 3 6 3 5 6 4 2 6 5 8 14 5 8 7 1 8 3 3 5 1 3 5 7 1 6 2 5 6 4 8 2 3 7 2 1 6 5 4 3 5 10 3 4 4 5 2 4 2 3 2 3 5 1 1 3 3 2 2 5 2 1 8 16 2 3 6 8 2 4 5 8 7 4 3 4 2 1 1 5 1 2 4 5 2 4 8 6 6 3 7 2 7 2 2 7 3 19 1 3 1 2 3...
output:
1 12 1 365214 0 1 45132 0 1 231 1 3742516 1 1 7 1437625 2514376 3762514 4376251 5143762 6251437 7625143 1 6271354 1 789165432 1 354612 1 45123 0 1 618432975 1 891270509 1 6521374 0 1 213 1 1243 2 12 21 0 1 351462 1 4356127 1 1324 1 231 1 3412 1 942367815 1 123 1 213 1 45321 ...
result:
ok 132887 numbers
Test #8:
score: 0
Accepted
time: 135ms
memory: 37440kb
input:
67812 6 32 2 3 4 6 1 2 2 4 2 6 3 4 1 4 4 5 1 5 3 6 1 6 6 3 3 6 2 6 4 5 5 6 2 3 1 3 2 6 1 2 2 4 2 1 1 2 4 6 1 2 2 6 3 6 1 4 2 6 2 3 4 3 4 2 7 31 6 3 4 7 1 4 6 4 3 2 6 2 2 5 3 4 2 3 6 2 5 7 7 4 6 2 1 4 1 6 1 3 4 3 4 7 6 1 1 2 5 3 3 4 3 4 5 1 1 4 5 4 2 7 4 7 1 5 5 4 6 1 7 19 1 2 1 4 3 5 1 6 1 4 2 5 1 7...
output:
1 563421 1 7432516 1 7532416 1 4257316 2 12 21 1 5463721 1 1 1 51672348 1 38174562 1 183005348 1 51463278 1 2314 1 428691705 1 2314 1 209642804 1 23514 1 1 1 613524 2 419682357 682357194 2 12 21 1 625341 1 1 1 3245671 2 132 231 1 21 1 6152347 2 12 21 1 781704274 1 8643215...
result:
ok 148213 numbers
Test #9:
score: 0
Accepted
time: 136ms
memory: 40516kb
input:
91345 2 12 2 1 2 1 2 1 1 2 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 1 2 2 2 1 1 2 7 24 1 2 4 6 5 2 7 1 2 4 3 6 6 4 7 4 4 3 2 4 6 1 6 1 3 7 4 3 7 1 2 7 1 3 7 1 7 4 5 1 5 7 6 7 6 7 1 4 3 4 1 3 1 3 1 2 1 3 7 22 7 5 4 1 5 1 2 1 7 2 3 5 6 7 4 2 4 7 1 4 1 6 5 4 1 6 2 7 1 3 6 3 7 2 1 4 4 2 1 2 6 3 3 5 5 17 1 5 2 5 4 ...
output:
2 12 21 2 12 21 0 0 0 1 34521 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 2 12 21 0 0 2 12 21 2 12 21 0 0 1 12 1 1 1 2143 2 12 21 0 2 12 21 0 0 0 2 12 21 0 0 2 12 21 0 0 0 0 2 12 21 0 0 0 0 1 4312 2 12 21 0 0 0 0 0 2 12 21 1 1 1 123 0 0 0 0 0 0 2 12 21 0 0 1 31254 0 0 0 0 0 0 0 0 0 0 2 ...
result:
ok 125201 numbers
Test #10:
score: 0
Accepted
time: 131ms
memory: 39984kb
input:
64447 3 4 1 2 2 3 3 1 3 2 6 21 4 3 4 6 6 3 3 5 4 6 6 2 1 5 2 5 1 5 3 4 5 2 3 1 3 1 1 6 1 5 4 1 5 1 4 2 4 6 3 6 6 5 6 13 3 2 4 1 6 5 3 5 2 5 5 2 5 3 3 4 6 3 6 5 1 6 4 3 3 2 8 32 7 3 4 2 1 4 7 4 5 4 7 1 4 3 5 6 1 4 3 4 4 2 5 7 1 7 1 7 7 8 1 4 5 1 8 6 3 8 2 8 3 7 3 4 5 4 1 7 3 6 7 6 1 3 1 5 3 2 3 6 6 4...
output:
2 123 231 1 251634 1 253416 1 28643715 1 231 3 35124 43512 51243 1 15234 1 312 1 5237461 1 15432 0 1 37645812 2 12 21 0 1 718392465 2 12 21 1 3124 0 1 312 1 684297513 1 41682735 1 42178356 1 231 2 21436875 36875142 1 532896471 1 261453 1 542631 1 1473526 1 24513 1 12 1 590...
result:
ok 132279 numbers
Test #11:
score: 0
Accepted
time: 126ms
memory: 40780kb
input:
67818 6 23 2 6 2 5 3 5 4 5 2 1 2 3 3 5 2 4 3 4 5 4 4 6 1 2 2 4 3 6 2 5 6 5 1 6 3 1 6 3 2 6 6 5 4 5 1 5 9 11 8 7 3 2 8 3 6 7 4 3 1 5 5 8 8 9 6 3 7 1 2 6 9 26 8 5 6 5 4 3 3 9 5 1 2 4 4 2 6 3 6 8 2 3 8 1 2 3 4 6 4 1 7 5 8 4 5 9 1 3 7 9 9 7 1 6 8 9 5 9 8 5 2 8 2 3 6 9 1 3 3 4 1 6 5 6 2 1 4 6 4 2 4 1 6 2...
output:
1 546312 1 432671589 1 397516842 1 562134 1 321 3 132 213 321 1 652978480 1 7426315 1 1675342 2 317289456 894562173 1 231 1 681429753 1 13654827 1 123 1 132 1 321645 1 7132654 1 81492334 1 431526 1 4321 1 437295681 1 24786315 1 562143 1 4231 1 7154362 1 83271456 1 132 1 1 ...
result:
ok 148279 numbers
Test #12:
score: 0
Accepted
time: 139ms
memory: 39744kb
input:
91112 1 0 9 19 2 7 7 9 2 8 6 5 4 5 2 4 8 1 1 9 1 8 4 2 2 8 7 4 9 3 9 3 8 1 8 5 1 7 6 8 3 5 1 0 4 17 1 2 4 3 3 4 1 2 1 3 1 3 3 4 1 4 2 3 4 2 2 1 3 4 1 4 1 3 1 2 2 4 3 1 3 5 2 1 1 2 3 1 3 2 3 1 4 5 2 1 3 1 1 3 3 4 3 2 3 22 3 2 2 3 2 3 3 2 1 2 1 3 2 1 2 1 3 2 1 2 1 2 3 1 3 2 3 2 2 3 1 2 2 1 1 3 2 1 3 2...
output:
1 1 0 1 1 0 0 1 2134 0 2 12 21 1 1 0 0 0 0 0 1 1 0 0 1 1 0 2 12 21 1 21 0 0 0 0 0 0 0 0 0 1 2431 0 0 0 0 2 12 21 1 1 0 0 0 0 0 2 12 21 0 0 0 0 0 0 2 12 21 0 2 12 21 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 12 21 1 1 0 0 1 4213 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1342 0 0 ...
result:
ok 124751 numbers
Test #13:
score: 0
Accepted
time: 124ms
memory: 39700kb
input:
64942 5 15 5 2 5 3 1 4 2 3 2 3 2 3 2 1 2 3 4 3 5 1 5 3 2 5 1 3 3 1 4 5 9 24 6 2 2 6 2 1 6 8 7 2 6 5 7 4 4 2 5 7 1 2 3 9 3 2 8 1 9 4 4 6 7 2 9 6 7 8 4 5 7 2 9 6 9 8 3 5 4 3 8 29 8 7 7 1 7 8 3 7 2 6 1 2 3 8 5 7 6 4 5 1 6 1 5 6 3 4 6 2 3 7 1 4 6 2 8 5 3 5 5 1 5 7 1 4 8 1 7 1 3 1 3 5 5 2 6 7 5 3 1 0 9 3...
output:
1 31452 1 812657439 0 1 1 1 739415826 1 12 1 3142 1 321 1 24513 1 698741532 2 12 21 0 1 859461723 1 25134 1 359174676 2 123 321 1 38267514 1 81753264 1 3214 1 1342 1 35214 1 5314627 1 87634512 1 35612487 1 7314265 1 213 1 123645 1 1 1 314256 1 98674518 1 51734826 1 1 1 ...
result:
ok 133220 numbers
Test #14:
score: 0
Accepted
time: 131ms
memory: 39648kb
input:
67710 3 11 3 2 3 2 1 2 1 3 3 1 3 2 1 3 3 2 1 2 1 2 2 3 2 13 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 8 16 2 7 2 8 3 8 2 1 7 3 2 5 8 4 8 3 5 3 2 7 4 6 7 1 6 7 1 2 7 8 6 8 1 0 9 15 3 1 8 2 4 9 7 9 3 8 2 4 2 8 6 4 9 3 5 1 6 9 6 7 1 5 3 9 5 6 8 25 1 4 6 1 3 2 1 3 1 2 6 5 8 6 6 2 8 1 6 5 1 7 8...
output:
1 231 2 12 21 2 38467125 53846712 1 1 1 824931567 1 32714568 1 387195264 1 2431 1 21453 1 34251 2 12 21 1 572136498 1 154362 1 67482531 1 231 1 25134 1 496021846 2 236154 542361 1 130853701 1 487915193 1 73684512 1 148395726 1 631524 1 83526147 1 123 1 1 2 12 21 1 126534 ...
result:
ok 148022 numbers
Test #15:
score: 0
Accepted
time: 135ms
memory: 41260kb
input:
91134 5 12 5 4 2 3 5 3 3 5 3 4 3 1 3 4 1 3 1 4 1 5 1 5 4 5 2 5 1 2 2 1 1 2 1 2 2 1 4 13 2 4 2 3 2 1 1 3 1 4 4 2 2 4 1 4 2 4 1 3 2 4 3 1 1 4 8 5 3 8 7 4 1 8 6 8 3 8 1 0 3 2 2 1 2 3 3 3 1 2 3 2 2 1 9 9 8 9 6 4 7 4 3 4 4 3 4 7 3 7 7 6 6 1 1 0 7 19 2 4 2 5 6 4 6 2 6 3 2 3 4 2 4 3 4 5 7 4 6 3 5 6 1 7 4 5...
output:
0 2 12 21 1 3142 0 1 1 0 1 321 0 1 1 0 0 2 12 21 1 21 0 2 12 21 0 1 312 2 12 21 0 0 1 132 0 0 0 0 0 0 0 0 0 1 231 0 0 0 0 2 12 21 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 2 12 21 0 0 0 0 1 1 0 0 2 12345 34521 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 2 12 21 0 0 0 0 0 0 0 0 0 2 12 21 0 0 1 1 0 0 0...
result:
ok 124996 numbers
Test #16:
score: 0
Accepted
time: 124ms
memory: 39540kb
input:
64745 1 0 6 29 6 1 4 6 2 1 6 2 2 4 2 6 5 1 2 4 2 5 4 3 2 6 6 1 2 6 2 5 1 3 2 5 2 5 2 3 5 4 5 3 3 5 6 3 2 1 2 6 2 6 4 1 2 1 6 3 2 6 3 15 2 3 2 1 3 1 2 1 1 2 2 1 1 3 2 3 2 3 2 3 2 3 1 3 2 3 2 1 1 3 8 28 2 1 2 5 6 8 7 4 3 8 5 1 5 1 3 4 1 7 4 5 5 3 8 3 2 7 2 4 8 5 8 4 6 7 2 8 8 7 8 3 8 5 2 4 2 8 8 6 3 5...
output:
1 1 1 135462 1 312 0 1 1 1 6417325 1 21435 1 153624 2 341526 634152 1 213 1 4123 1 3412 1 7134256 1 13245 1 1374652 1 32145 1 806432103 1 83526714 1 32451 1 814329565 1 165423 1 24531 1 521880892 1 81367452 2 12 21 1 31542 2 12 21 1 132 1 127835467 4 218937465 465218937 5...
result:
ok 132955 numbers
Test #17:
score: 0
Accepted
time: 127ms
memory: 40788kb
input:
67788 6 16 1 6 3 5 3 5 5 2 5 4 3 5 5 6 5 3 4 1 1 6 4 5 6 1 3 6 1 2 2 4 3 6 1 0 6 18 1 2 3 2 5 3 5 1 3 6 5 4 2 1 4 3 3 1 3 2 3 1 6 2 5 1 4 5 4 2 3 5 1 3 4 2 2 10 2 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 1 0 2 7 2 1 2 1 2 1 1 2 2 1 2 1 2 1 3 8 1 3 3 2 1 2 3 2 2 1 3 2 1 2 3 2 10 15 3 6 3 5 9 8 4 3 5 10 ...
output:
1 612453 1 1 1 621354 2 12 21 1 1 2 12 21 2 213 321 1 607198422 2 1432 3241 1 87645231 2 3412 4123 2 12 21 1 163245 2 3241 4123 2 12 21 2 213 321 1 1 2 12 21 3 482513976 648251397 764825139 1 51342 1 123 1 192574638 2 12 21 1 75418632 1 808163259 1 842965371 2 12 21 1 4123...
result:
ok 148473 numbers
Test #18:
score: 0
Accepted
time: 127ms
memory: 40900kb
input:
90788 5 17 3 5 5 3 4 5 3 1 5 4 1 5 5 2 2 5 1 5 3 4 5 2 4 5 1 3 4 1 2 5 2 4 2 3 3 9 2 3 2 3 2 1 3 2 2 3 2 1 3 1 3 1 2 1 4 22 4 3 2 1 4 1 2 3 1 4 3 2 4 1 3 2 2 3 3 1 4 3 3 4 1 4 3 2 3 1 4 2 4 3 4 3 1 2 1 3 3 1 4 2 10 12 2 5 10 2 10 7 10 3 2 5 9 10 10 6 5 4 3 10 3 10 1 2 3 10 3 6 1 2 3 1 3 1 3 1 2 3 1 ...
output:
0 0 0 0 3 123 231 312 0 0 0 0 0 0 0 0 0 2 12 21 0 0 0 0 0 1 132 2 12 21 0 0 0 0 1 1 0 0 1 321 0 0 1 1 2 12 21 0 2 12 21 0 0 0 0 0 0 1 123 1 12 0 1 1 1 1 0 0 1 1 0 0 0 0 0 2 12 21 0 0 0 0 0 0 0 0 0 3 132 213 321 0 1 321 0 1 67254138 0 0 0 1 1 0 1 1 0 0 0 0 2 12 21 0 0 0 0 1 1 1 ...
result:
ok 123950 numbers
Test #19:
score: 0
Accepted
time: 129ms
memory: 40520kb
input:
64720 3 4 1 3 1 2 1 3 3 1 9 24 9 3 2 3 4 7 1 9 7 2 1 3 8 5 8 4 9 1 4 3 4 5 9 3 1 7 5 6 9 8 6 1 4 3 3 4 1 4 8 6 5 7 3 7 8 7 1 3 2 14 1 2 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 7 28 4 2 5 4 4 3 6 2 5 4 6 2 4 3 7 1 4 7 6 2 3 2 6 1 4 6 4 6 2 1 7 5 5 2 5 7 2 3 6 4 5 6 1 6 5 4 7 6 6 3 7 2 5 4...
output:
1 312 1 723456198 2 12 21 1 3216475 0 3 2537614 3761425 5376142 1 31842567 2 12 21 1 132 0 1 25431 1 5143627 0 0 1 12 1 36812754 1 217940400 1 123 1 231 0 1 13425 1 273148596 1 312 2 12 21 1 312 1 632145 1 1456327 1 52178364 1 1 2 24135 35124 1 3421 2 12 21 1 352750555 1 ...
result:
ok 133219 numbers
Test #20:
score: 0
Accepted
time: 129ms
memory: 40192kb
input:
67944 9 29 5 4 3 1 7 3 7 5 8 4 7 4 8 1 4 1 1 2 5 3 1 6 9 6 9 4 7 5 6 9 8 1 3 5 7 5 5 6 5 7 5 1 7 9 4 6 3 2 5 8 4 9 8 2 2 8 8 3 5 16 4 3 5 4 1 4 5 3 5 1 1 3 5 1 3 4 5 2 5 1 1 5 2 4 4 2 1 3 3 1 5 1 9 33 6 5 3 8 6 7 8 9 2 4 4 8 4 5 2 3 4 3 7 8 7 9 7 1 6 1 7 9 4 3 6 2 1 3 6 9 4 6 6 9 1 7 4 5 4 2 5 7 6 8...
output:
1 694128357 1 24315 1 938715246 1 563412 1 132 1 329546781 1 43512 2 12 21 1 32145 2 123 231 1 782543169 1 213 1 541326 1 123 1 26573481 1 5741263 1 3526174 1 3756412 1 968740500 1 5461237 1 231 1 257198308 1 3214 1 568024263 1 1 1 4312 1 4723615 2 34125 41253 1 321 1 63...
result:
ok 148525 numbers
Test #21:
score: 0
Accepted
time: 132ms
memory: 40580kb
input:
90784 2 2 1 2 1 2 10 9 2 10 5 3 4 1 7 9 6 1 10 5 5 2 10 3 10 5 3 10 2 1 3 2 2 3 2 1 1 2 3 2 3 1 1 2 3 2 2 3 7 4 2 1 3 1 6 3 7 5 10 3 2 6 3 10 2 7 9 4 1 7 2 6 2 8 2 4 5 9 5 4 5 2 2 4 5 4 4 5 1 3 3 4 1 4 3 1 8 25 4 3 2 4 6 4 1 7 7 6 3 6 8 4 2 8 3 6 4 6 6 5 7 8 6 5 8 3 4 7 3 1 6 5 4 2 4 1 4 5 4 8 5 6 6...
output:
1 12 0 1 123 0 0 0 0 0 0 0 1 321 0 0 0 0 0 2 12 21 0 0 2 12 21 1 1 0 0 0 2 12 21 2 12 21 0 2 12 21 0 0 0 0 2 12 21 0 1 1 1 1 0 0 1 1 0 0 2 12 21 1 12 0 0 0 2 12 21 0 0 1 1 0 0 1 312 0 0 2 12 21 0 0 0 0 0 1 1 0 0 1 1 2 12 21 0 0 1 1 0 0 0 1 1 0 2 12 21 2 12 21 0 0 0 2 12 21 ...
result:
ok 124129 numbers
Test #22:
score: 0
Accepted
time: 124ms
memory: 39956kb
input:
64718 1 0 7 19 3 7 5 7 5 6 7 5 3 6 1 3 1 4 6 7 4 5 1 6 1 3 6 3 4 3 2 1 4 1 4 7 1 3 3 2 3 6 7 11 5 6 6 2 3 7 7 1 2 5 2 3 6 4 6 4 1 6 6 4 4 3 9 17 3 9 6 1 5 4 4 6 1 2 4 6 7 6 1 6 2 7 4 3 8 3 2 8 7 2 8 2 3 8 1 5 9 3 2 16 2 1 2 1 2 1 1 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 3 7 3 1 2 1 3 2 2 ...
output:
1 1 1 7563214 1 4371625 1 938276154 2 12 21 2 132 213 1 24531 1 391286754 1 21543 1 341972498 1 1 1 1253467 0 2 785392416 853924167 1 42531 1 64135287 0 1 452916738 1 619375428 2 1243 2431 0 1 460072575 2 12 21 0 1 321 1 836752419 1 34152 1 2431 1 23541 2 3412 4123 0 2 12 2...
result:
ok 133061 numbers
Test #23:
score: 0
Accepted
time: 128ms
memory: 39324kb
input:
67838 5 15 4 2 1 4 3 4 2 1 2 5 5 1 3 2 2 4 4 1 4 1 2 1 2 3 3 4 1 5 4 1 7 25 6 4 1 2 6 3 5 4 6 7 3 7 3 4 6 3 5 6 2 5 5 1 6 7 6 7 7 3 5 4 6 5 6 2 5 4 5 3 2 1 2 4 4 3 4 1 5 2 4 3 10 32 2 1 7 6 10 7 9 7 5 8 4 10 3 9 5 9 5 6 4 2 9 6 9 8 4 3 5 2 3 7 5 6 3 5 10 1 6 2 9 10 3 5 4 7 9 2 4 1 9 6 10 4 1 8 8 7 5...
output:
1 51423 1 7341256 1 762159987 1 34612578 1 5364721 1 690035420 3 1756234 4175623 7562341 1 971260441 1 312 1 3412 1 493562178 1 1 1 1 1 312456 1 231 1 679905391 6 164532 216453 321645 453216 532164 645321 1 132 1 4231 1 43521 1 1243 1 52341 1 17458236 1 748195263 1 1 2 14735...
result:
ok 148527 numbers
Test #24:
score: 0
Accepted
time: 130ms
memory: 39404kb
input:
91081 10 26 5 8 3 8 7 1 2 4 1 2 10 9 4 1 9 6 1 7 5 3 8 4 7 5 1 3 10 1 8 2 10 8 8 7 2 5 2 4 1 2 10 7 3 4 5 1 2 8 9 2 6 8 10 2 7 9 1 7 5 17 1 5 5 2 4 1 2 3 5 4 2 4 2 4 4 3 1 3 4 1 4 2 3 2 3 4 4 1 1 2 4 1 4 5 1 0 6 12 3 1 6 5 5 4 5 6 3 4 6 1 4 3 2 5 1 6 1 4 3 4 1 4 8 14 5 7 5 7 2 3 3 6 1 2 7 6 7 4 5 7 ...
output:
0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 2 12 21 1 21 0 0 0 0 0 1 321 0 0 0 0 1 1 0 0 2 12 21 0 0 0 0 0 2 12 21 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 3421 0 2 12 21 0 0 0 1 1 0 0 0 0 0 0 2 231 312 0 2 12 21 0 0 0 0 2 12 21 0 1 1 0 0 0 0 2 12 21 2 12 21 0 2 123 321 0 1 1 ...
result:
ok 124817 numbers
Test #25:
score: 0
Accepted
time: 117ms
memory: 40900kb
input:
64614 7 21 1 4 1 5 6 1 6 7 1 6 1 3 6 1 6 3 6 5 5 3 7 2 6 3 4 7 2 5 3 4 7 5 6 7 4 2 1 2 1 7 7 1 10 28 5 9 3 2 9 6 4 1 9 3 5 8 7 6 5 8 7 1 10 9 6 4 5 2 9 6 10 4 6 8 2 7 2 4 5 10 10 7 8 7 3 9 5 6 10 9 10 1 1 8 3 8 2 5 6 9 10 30 7 4 3 1 4 5 7 2 8 4 7 10 4 1 8 3 1 4 2 6 1 2 7 5 6 10 3 2 7 5 3 2 10 7 1 2 ...
output:
1 2534716 1 187693232 0 1 825619783 2 152364 523641 1 4231 1 213 1 462351 1 1 1 132 0 0 1 594376821 0 1 650053133 1 326154 1 1362745 1 4123 1 1 1 859732146 1 792814365 1 27534618 1 87265134 1 745628139 1 4123 1 5673241 1 1 1 45231 2 12 21 1 1 1 65713842 1 645803749 1 3657...
result:
ok 132652 numbers
Test #26:
score: 0
Accepted
time: 124ms
memory: 39396kb
input:
67618 3 10 3 2 3 1 3 1 2 3 3 1 3 1 1 2 2 1 3 2 3 1 10 9 3 4 5 9 9 7 2 10 8 5 10 3 7 6 6 1 1 2 10 28 2 4 7 4 4 2 1 8 4 6 4 8 5 2 6 2 3 5 8 2 9 5 6 1 1 4 1 9 7 8 9 8 10 7 7 5 10 8 2 8 4 2 3 5 5 3 5 8 5 8 9 8 5 2 3 10 5 25 4 2 4 3 5 1 4 1 4 2 2 1 5 2 3 1 2 3 3 1 3 4 3 2 1 5 2 5 2 1 3 2 5 1 5 1 2 1 4 5 ...
output:
1 123 1 597612978 1 246195351 1 15234 1 2351746 1 1 1 961374852 1 4213 2 12 21 2 2761453 6145327 1 7341256 1 2465317 1 279864531 2 213 312 1 21543 2 12 21 1 25341 2 12 21 1 876954312 1 76541328 2 451263 634512 1 1 1 4726315 1 132 1 380914827 1 51423 1 21 1 4312 1 42615873...
result:
ok 147867 numbers
Test #27:
score: 0
Accepted
time: 127ms
memory: 40748kb
input:
91041 4 15 4 2 3 2 1 3 4 3 1 4 4 1 3 4 4 2 1 4 4 2 3 1 1 4 4 3 2 4 2 1 2 4 1 2 1 2 2 1 1 2 2 5 1 2 2 1 2 1 2 1 2 1 8 7 1 7 1 8 1 7 7 6 8 5 5 2 3 7 2 4 1 2 1 2 1 2 2 1 5 11 4 1 1 5 1 5 5 3 5 1 5 2 1 5 3 2 3 2 4 1 1 5 9 6 9 8 9 8 6 3 4 7 9 6 4 8 4 11 3 1 3 1 3 4 3 2 3 1 2 3 4 3 3 1 2 1 4 1 3 2 9 18 6 ...
output:
0 2 12 21 2 12 21 0 2 12 21 0 0 0 0 0 0 0 1 1 2 12 21 0 0 0 0 0 0 0 0 0 0 0 0 1 1423 0 1 1 1 1 0 0 0 0 1 4312 0 0 0 0 0 0 1 312 0 0 1 1 1 3421 0 0 1 21 0 0 1 12 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 2 12 21 0 0 0 0 0 0 0 2 12 21 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1324 1...
result:
ok 124640 numbers
Test #28:
score: 0
Accepted
time: 128ms
memory: 40640kb
input:
64643 10 14 9 10 9 7 8 6 3 8 6 2 4 9 5 4 2 3 10 5 2 7 1 3 7 1 8 4 4 8 3 25 3 2 1 3 3 1 1 2 3 2 1 2 3 2 3 1 3 1 3 2 1 2 3 2 3 2 1 2 1 2 1 2 3 2 3 2 2 1 1 2 3 1 3 2 3 2 1 2 1 2 10 18 1 10 3 4 10 7 3 9 9 1 9 4 2 10 1 5 6 4 4 7 2 6 9 2 4 8 6 3 8 2 7 5 9 6 5 4 8 28 8 5 3 5 4 8 4 6 1 6 5 6 6 5 4 8 3 6 1 7...
output:
0 1 213 1 754826321 1 71658234 2 1574263 5742631 1 643125 1 1 2 12 21 1 4312 1 202378631 1 682075903 1 76821383 0 2 123 321 1 1 2 132 321 1 3142 1 534216 2 12 21 0 1 678426086 2 42538176 64253817 1 4732156 1 46173528 2 345291786 634529178 1 24135 1 13425 1 15287364 1 1643587...
result:
ok 132863 numbers
Test #29:
score: 0
Accepted
time: 131ms
memory: 40560kb
input:
67901 9 16 7 8 8 3 4 5 1 6 9 2 3 9 5 1 7 4 6 7 8 4 8 4 7 1 9 8 6 4 2 7 3 6 3 12 3 2 2 3 2 1 1 2 3 2 3 2 3 2 2 1 3 2 3 1 3 1 3 2 4 8 1 3 4 3 2 4 4 2 3 4 2 1 4 1 2 3 3 3 1 3 3 2 2 1 7 16 5 3 5 1 1 3 6 7 3 6 3 5 4 7 1 4 3 6 7 3 7 2 5 6 2 6 5 3 1 6 4 7 4 3 1 2 3 1 4 3 3 10 3 1 1 2 2 3 3 1 3 1 3 1 3 2 2 ...
output:
1 451678392 1 123 1 1342 3 132 213 321 1 2673514 1 4312 1 123 1 31452 1 12354 1 36815436 2 12 21 2 12 21 1 753004361 1 1 1 83214765 1 5264731 1 364152 1 62457813 1 25143 1 1 1 27184563 1 4132 1 3124 1 634521 1 132 1 649783152 2 12 21 1 321 1 75438126 1 12345 2 12 21 1 ...
result:
ok 148469 numbers
Test #30:
score: 0
Accepted
time: 135ms
memory: 40904kb
input:
90746 9 9 3 6 6 3 1 4 9 6 7 6 6 7 4 1 5 4 3 9 6 24 5 4 1 4 3 5 6 4 2 3 4 1 3 2 5 3 2 4 2 6 2 6 6 3 4 3 3 5 1 3 6 3 3 2 6 3 2 6 6 2 1 5 6 2 4 5 5 3 4 12 4 2 3 1 2 4 1 4 4 2 2 3 2 3 3 1 3 1 4 1 3 1 3 4 7 3 3 6 2 7 6 7 8 14 3 2 2 6 4 3 5 3 3 4 3 6 2 7 1 7 1 2 3 2 4 6 3 5 7 8 3 8 6 17 4 3 5 2 5 3 1 2 1 ...
output:
0 0 1 1423 0 0 1 361245 0 1 4231 2 12 21 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 2 132 321 0 0 1 1 1 312 1 1 0 0 0 1 1 1 132 1 12 0 0 1 32514 2 12 21 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 2 12 21 0 0 2 12 21 0 0 0 1 123 0 2 213 321 0 0 0 1 12 0 0 0 0 0 0 2 12 21 ...
result:
ok 124350 numbers
Test #31:
score: 0
Accepted
time: 124ms
memory: 40576kb
input:
64449 9 18 6 2 8 5 6 5 3 6 8 9 3 6 5 7 9 6 4 5 8 7 8 5 1 3 2 1 3 5 2 6 3 1 7 8 6 9 9 13 6 9 5 7 8 1 6 8 1 3 5 8 7 5 9 2 7 1 3 9 2 6 8 5 4 1 6 13 4 5 1 4 4 2 6 2 6 1 6 1 2 4 6 1 2 6 6 3 5 1 6 5 3 6 6 23 1 6 2 4 2 5 1 6 5 4 3 4 5 4 6 2 1 2 5 4 2 4 2 3 5 6 2 1 2 3 4 5 1 2 6 5 4 3 2 6 1 4 6 3 2 6 3 8 2 ...
output:
1 457896213 1 413926857 1 514263 1 345621 2 123 321 1 23145 0 1 5134672 1 1 1 1 1 2341 1 1 1 1 1 562413 1 1 1 51324 1 251463 1 1 1 1 1 5432167 2 12 21 1 469258371 1 354621 1 52431 1 41352 1 26178435 1 53241 1 27613485 2 12 21 1 2143 1 562341 1 4312 1 1 0 1 4213 0 3 4...
result:
ok 132077 numbers
Test #32:
score: 0
Accepted
time: 4ms
memory: 40544kb
input:
1 1 0
output:
1 1
result:
ok 2 number(s): "1 1"
Test #33:
score: -100
Wrong Answer
time: 191ms
memory: 41200kb
input:
6940 26 139 16 2 17 12 22 10 19 18 26 15 1 25 11 4 16 21 20 2 2 16 6 2 14 22 19 16 26 21 14 9 6 19 16 8 24 8 2 11 20 5 7 24 5 7 13 25 14 23 19 1 14 9 8 23 9 1 6 14 12 23 20 10 3 14 18 26 15 1 7 5 26 2 13 11 22 11 17 25 6 23 5 10 12 8 15 12 23 10 9 14 12 23 10 22 21 8 26 5 8 13 15 1 26 22 3 10 21 17 ...
output:
1 803039395 1 679703927 0 1 321 1 263139408 1 708258723 1 502336119 1 971692203 1 63736713 1 761840921 1 749807540 1 562280948 1 386746264 1 611363905 1 1 0 1 555755517 1 11166572 1 914077790 1 247021350 0 1 436089852 1 9147086 1 68132479 1 632921663 1 585825604 1 899090716 1...
result:
wrong answer 5th numbers differ - expected: '1', found: '0'