QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#314150 | #8166. Almost Large | ucup-team2303# | WA | 630ms | 56260kb | C++14 | 2.1kb | 2024-01-25 13:30:56 | 2024-01-25 13:30:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001];
bool v[600001][13][3],vi[1000001];
char s[1000001];
struct p{int q,w,e;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
queue<p> qu;
void ins(int qq,int ww,int ee)
{
if(ww==12&&!vi[qq]) return;
if(v[qq][ww][ee]) return;
if(ww==12&&qq==d[a])
{
printf("Yes");
exit(0);
}
v[qq][ww][ee]=1;
qu.push(p{qq,ww,ee});
}
void work(long long qq,long long ww,long long ee)
{
if(ww==12)
{
int tt=qq,gg=1;cn=0;
for(int i=0;i<12;i++)
{
st[cn++]=tt%3,tt/=3;
}
for(int i=0;i<12;i++)
{
for(int j=0;j<=st[i];j++)
{
ins(qq-st[i]*gg+j*gg,i,j);
}
gg=gg*3;
}
}
else
{
ins(qq,12,0);
int tt=qq,gg=1;cn=0;
for(int i=0;i<12;i++)
{
st[cn++]=tt%3,tt/=3;
}
for(int i=0;i<cn;i++)
{
if(st[i]<2&&i!=ww)
{
ins(qq+gg,ww,ee);
// dfs(qq+gg,ww,ee);
}
gg=gg*3;
}
}
}
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
scanf("%lld",&a);
for(int i=1;i<=a;i++)
{
scanf("%lld",&d[i]);
vi[d[i]]=1;
}
ins(d[1],12,0);
while(!qu.empty())
{
p r=qu.front();qu.pop();
work(r.q,r.w,r.e);
}
printf("No");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 26996kb
input:
2 21 14
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 115ms
memory: 50584kb
input:
2 12 1
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 115ms
memory: 50644kb
input:
5 5 15 45 135 405
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 105ms
memory: 52528kb
input:
133729 515927 251707 509591 317498 177389 461753 275297 7848 452936 13695 394604 125096 242390 450018 501210 126212 64950 263819 216408 528515 454055 530346 241575 397712 524748 322154 60967 469683 464304 390612 215474 271893 127704 380804 390268 391984 401683 315101 523057 462146 194859 259610 4680...
output:
Yes
result:
ok answer is YES
Test #5:
score: 0
Accepted
time: 630ms
memory: 55168kb
input:
147249 527398 156678 5013 10368 17399 404399 217450 522971 155321 137708 345490 200329 199022 345117 528603 317293 67005 130459 30924 64105 394479 346479 136837 348286 469655 20584 530096 17403 74005 411855 519402 345524 406285 466066 155362 336093 353489 89402 215173 316455 86564 219312 275911 5142...
output:
Yes
result:
ok answer is YES
Test #6:
score: 0
Accepted
time: 203ms
memory: 55492kb
input:
154864 161885 172921 134934 393030 407706 454939 472219 487595 306439 302673 133875 490411 160434 294750 302400 459353 126961 297736 516062 411665 526210 281273 488744 411552 258834 79760 153295 463225 334602 395999 260123 127474 332557 456901 368795 432484 340435 478696 373285 115549 76099 174426 1...
output:
Yes
result:
ok answer is YES
Test #7:
score: 0
Accepted
time: 461ms
memory: 56224kb
input:
63572 336255 347207 500607 340509 391257 233454 476378 424093 91856 141952 452955 247724 466197 406255 62549 292873 4013 335193 254192 62977 52420 245444 520397 513186 246995 291290 40810 273443 136933 375866 192240 81675 276874 314671 330546 350403 28320 355536 389101 86751 300940 10450 299066 3188...
output:
Yes
result:
ok answer is YES
Test #8:
score: 0
Accepted
time: 396ms
memory: 54688kb
input:
63829 316865 74162 324739 305131 229923 463058 279311 237746 28582 257558 206932 447230 202462 181752 372628 469925 530359 361909 16297 99464 441119 451838 80051 443822 357373 378963 229930 515212 480614 184350 221515 327085 339769 407134 318770 179961 50736 55318 522509 355408 229777 212902 59870 4...
output:
Yes
result:
ok answer is YES
Test #9:
score: 0
Accepted
time: 494ms
memory: 56260kb
input:
66300 498574 249399 472527 39518 368230 401160 286065 203002 203380 390080 472426 243647 413311 318083 505420 10196 213875 36281 50044 104900 285602 505210 446922 393346 472415 344244 252238 298178 281757 502751 328216 308348 91687 194157 304780 314634 292092 255665 354178 20507 404232 82270 174 655...
output:
Yes
result:
ok answer is YES
Test #10:
score: 0
Accepted
time: 323ms
memory: 52404kb
input:
66115 62089 450098 41561 191728 39886 311800 521782 308368 148534 170885 267088 327438 444016 73879 170891 526128 262015 209834 203906 252727 428679 507414 265655 303411 295759 106683 528647 128909 417598 20174 83715 474612 93617 83592 516378 417746 290446 292113 48384 145560 192004 393050 52252 109...
output:
No
result:
ok answer is NO
Test #11:
score: 0
Accepted
time: 305ms
memory: 55504kb
input:
53788 420916 157883 340502 18615 88238 449119 246036 244635 404627 512930 506346 514674 356674 402440 120570 156822 118152 41839 138733 256798 281838 121047 16425 376388 511313 103964 380932 115266 924 62074 177569 265724 358136 417402 223292 324569 399208 247245 183715 338535 458902 191058 319308 3...
output:
No
result:
ok answer is NO
Test #12:
score: 0
Accepted
time: 293ms
memory: 55052kb
input:
91639 418076 40193 213136 40918 398440 48622 264979 280637 260361 224127 74066 275916 429505 14185 183468 259153 461015 20091 253894 79106 472110 245549 284748 104215 269369 42046 430809 422216 94315 457526 390666 471060 99034 50627 417025 2351 357866 365412 382166 187616 37592 225668 274396 72129 3...
output:
No
result:
ok answer is NO
Test #13:
score: 0
Accepted
time: 135ms
memory: 47724kb
input:
58160 292385 285328 199656 167096 225767 492816 494905 120456 435730 124311 21606 439375 474228 54926 53573 178017 474714 405869 24514 172817 351500 345523 121821 401581 518332 242361 170395 467765 142918 296769 115136 468977 82819 141450 137967 438784 113558 54050 379968 83698 401794 63972 353870 2...
output:
No
result:
ok answer is NO
Test #14:
score: 0
Accepted
time: 127ms
memory: 50552kb
input:
65650 86662 382083 44859 452176 87562 304759 6870 59607 465941 463033 241293 493000 62436 312824 285685 479424 128945 432211 515232 23525 88853 217640 458938 255273 75281 238467 432052 388472 64356 157854 83497 141453 157856 407903 405805 462655 300988 462998 102980 380738 328896 263925 238126 26624...
output:
No
result:
ok answer is NO
Test #15:
score: 0
Accepted
time: 116ms
memory: 49980kb
input:
53286 353564 67122 318031 452393 62410 295035 240007 487333 510207 14158 443924 317573 443166 501387 246243 118638 52368 156680 390419 103859 294785 35097 482647 252085 72802 347577 214612 487162 126802 361380 1425 116169 24848 169657 405753 119947 309884 149273 155193 156725 470464 246090 334572 22...
output:
No
result:
ok answer is NO
Test #16:
score: -100
Wrong Answer
time: 183ms
memory: 52172kb
input:
2 0 531440
output:
No
result:
wrong answer expected YES, found NO