QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#384390 | #6748. Spin the Wheel | fzx | WA | 64ms | 6508kb | C++14 | 878b | 2024-04-09 22:42:50 | 2024-04-09 22:42:51 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=2e5+5;
int n,a[INF],b[INF];
signed main()
{
ios::sync_with_stdio(false);
cin>>n;
for (int i=0;i<n;i++) cin>>a[i];
int res=1e18,fl=0;;
for (int i=0;i<n;i++)
if (i*a[1]%n!=a[i]) fl=1;
if (!fl) res=min(res,a[1]);
for (int i=0;i<n;i++) b[i]=a[i]-i,b[i]%=n,b[i]+=n,b[i]%=n;
for (int i=0;i<n;i++) b[i+n]=b[i];
for (int y=1;y<n;y++) {
int fl=0;
for (int i=0;i<min(100ll,n);i++)
if (b[1+y]*i%n!=b[i+y]) fl=1;
if (!fl) res=min(res,b[1+y]+2);
}
for (int i=0;i<n;i++) b[i]=a[i],b[i]%=n,b[i]+=n,b[i]%=n;
for (int i=0;i<n;i++) b[i+n]=b[i];
for (int y=1;y<n;y++) {
int fl=0;
for (int i=0;i<min(100ll,n);i++)
if (b[1+y]*i%n!=b[i+y]) fl=1;
if (!fl) res=min(res,b[1+y]+1);
}
if (res>1e9) cout<<"-1\n";
else cout<<res<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 64ms
memory: 5944kb
input:
100000 0 55555 11110 66665 22220 77775 33330 88885 44440 99995 55550 11105 66660 22215 77770 33325 88880 44435 99990 55545 11100 66655 22210 77765 33320 88875 44430 99985 55540 11095 66650 22205 77760 33315 88870 44425 99980 55535 11090 66645 22200 77755 33310 88865 44420 99975 55530 11085 66640 221...
output:
55555
result:
ok 1 number(s): "55555"
Test #3:
score: 0
Accepted
time: 63ms
memory: 6360kb
input:
100000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 500...
output:
50000
result:
ok 1 number(s): "50000"
Test #4:
score: 0
Accepted
time: 64ms
memory: 6280kb
input:
100000 1 401 801 1201 1601 2001 2401 2801 3201 3601 4001 4401 4801 5201 5601 6001 6401 6801 7201 7601 8001 8401 8801 9201 9601 10001 10401 10801 11201 11601 12001 12401 12801 13201 13601 14001 14401 14801 15201 15601 16001 16401 16801 17201 17601 18001 18401 18801 19201 19601 20001 20401 20801 21201...
output:
401
result:
ok 1 number(s): "401"
Test #5:
score: 0
Accepted
time: 64ms
memory: 6020kb
input:
100000 37631 70399 3167 35935 68703 1471 34239 67007 99775 32543 65311 98079 30847 63615 96383 29151 61919 94687 27455 60223 92991 25759 58527 91295 24063 56831 89599 22367 55135 87903 20671 53439 86207 18975 51743 84511 17279 50047 82815 15583 48351 81119 13887 46655 79423 12191 44959 77727 10495 4...
output:
32769
result:
ok 1 number(s): "32769"
Test #6:
score: 0
Accepted
time: 64ms
memory: 5948kb
input:
100000 71294 42588 13882 85176 56470 27764 99058 70352 41646 12940 84234 55528 26822 98116 69410 40704 11998 83292 54586 25880 97174 68468 39762 11056 82350 53644 24938 96232 67526 38820 10114 81408 52702 23996 95290 66584 37878 9172 80466 51760 23054 94348 65642 36936 8230 79524 50818 22112 93406 6...
output:
71295
result:
ok 1 number(s): "71295"
Test #7:
score: 0
Accepted
time: 63ms
memory: 5944kb
input:
100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 61ms
memory: 5948kb
input:
100000 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294 71294...
output:
100001
result:
ok 1 number(s): "100001"
Test #9:
score: 0
Accepted
time: 53ms
memory: 6324kb
input:
83189 44297 43624 42951 42278 41605 40932 40259 39586 38913 38240 37567 36894 36221 35548 34875 34202 33529 32856 32183 31510 30837 30164 29491 28818 28145 27472 26799 26126 25453 24780 24107 23434 22761 22088 21415 20742 20069 19396 18723 18050 17377 16704 16031 15358 14685 14012 13339 12666 11993 ...
output:
82517
result:
ok 1 number(s): "82517"
Test #10:
score: 0
Accepted
time: 43ms
memory: 5924kb
input:
66285 65229 20947 42950 64953 20671 42674 64677 20395 42398 64401 20119 42122 64125 19843 41846 63849 19567 41570 63573 19291 41294 63297 19015 41018 63021 18739 40742 62745 18463 40466 62469 18187 40190 62193 17911 39914 61917 17635 39638 61641 17359 39362 61365 17083 39086 61089 16807 38810 60813 ...
output:
22004
result:
ok 1 number(s): "22004"
Test #11:
score: 0
Accepted
time: 0ms
memory: 5688kb
input:
2236 485 1160 1835 274 949 1624 63 738 1413 2088 527 1202 1877 316 991 1666 105 780 1455 2130 569 1244 1919 358 1033 1708 147 822 1497 2172 611 1286 1961 400 1075 1750 189 864 1539 2214 653 1328 2003 442 1117 1792 231 906 1581 20 695 1370 2045 484 1159 1834 273 948 1623 62 737 1412 2087 526 1201 187...
output:
676
result:
ok 1 number(s): "676"
Test #12:
score: 0
Accepted
time: 26ms
memory: 4608kb
input:
39250 12616 34467 17068 38919 21520 4121 25972 8573 30424 13025 34876 17477 78 21929 4530 26381 8982 30833 13434 35285 17886 487 22338 4939 26790 9391 31242 13843 35694 18295 896 22747 5348 27199 9800 31651 14252 36103 18704 1305 23156 5757 27608 10209 32060 14661 36512 19113 1714 23565 6166 28017 1...
output:
21852
result:
ok 1 number(s): "21852"
Test #13:
score: 0
Accepted
time: 39ms
memory: 5060kb
input:
60347 32482 25809 19136 12463 5790 59464 52791 46118 39445 32772 26099 19426 12753 6080 59754 53081 46408 39735 33062 26389 19716 13043 6370 60044 53371 46698 40025 33352 26679 20006 13333 6660 60334 53661 46988 40315 33642 26969 20296 13623 6950 277 53951 47278 40605 33932 27259 20586 13913 7240 56...
output:
53675
result:
ok 1 number(s): "53675"
Test #14:
score: 0
Accepted
time: 55ms
memory: 5660kb
input:
85249 69604 45461 21318 82424 58281 34138 9995 71101 46958 22815 83921 59778 35635 11492 72598 48455 24312 169 61275 37132 12989 74095 49952 25809 1666 62772 38629 14486 75592 51449 27306 3163 64269 40126 15983 77089 52946 28803 4660 65766 41623 17480 78586 54443 30300 6157 67263 43120 18977 80083 5...
output:
61107
result:
ok 1 number(s): "61107"
Test #15:
score: 0
Accepted
time: 2ms
memory: 5800kb
input:
1735 1421 1499 1577 1655 1733 76 154 232 310 388 466 544 622 700 778 856 934 1012 1090 1168 1246 1324 1402 1480 1558 1636 1714 57 135 213 291 369 447 525 603 681 759 837 915 993 1071 1149 1227 1305 1383 1461 1539 1617 1695 38 116 194 272 350 428 506 584 662 740 818 896 974 1052 1130 1208 1286 1364 1...
output:
79
result:
ok 1 number(s): "79"
Test #16:
score: -100
Wrong Answer
time: 64ms
memory: 6508kb
input:
100000 966 72645 59036 45427 31818 18209 4600 90991 77382 63773 50164 36555 22946 9337 95728 82119 68510 54901 41292 27683 14074 465 86856 73247 59638 46029 32420 18811 5202 91593 77984 64375 50766 37157 23548 9939 96330 82721 69112 55503 41894 28285 14676 1067 87458 73849 60240 46631 33022 19413 58...
output:
86392
result:
wrong answer 1st numbers differ - expected: '-1', found: '86392'