QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#475451#6748. Spin the Wheel1903331632AC ✓6ms3992kbC++20811b2024-07-13 14:50:262024-07-13 14:50:27

Judging History

你现在查看的是最新测评结果

  • [2024-07-13 14:50:27]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:3992kb
  • [2024-07-13 14:50:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int cha = (a[1] - a[0] + n) % n;
    for (int i = 1; i < n; i++)
    {
        if ((a[i - 1] + cha) % n != a[i])
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    if (cha == 0)
    {
        if (cha == 0 && a[0] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        else
            cout << n + 1 << endl;
        return 0;
    }
    if (a[0] == 0)
    {
        cout << cha << endl;
    }
    else
    {
        cout << cha + 1 << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3812kb

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: 4ms
memory: 3796kb

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: 2ms
memory: 3828kb

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: 6ms
memory: 3888kb

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: 5ms
memory: 3816kb

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: 3ms
memory: 3992kb

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: 5ms
memory: 3800kb

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: 4ms
memory: 3840kb

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: 4ms
memory: 3572kb

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: 3832kb

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: 2ms
memory: 3528kb

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: 3ms
memory: 3612kb

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: 4ms
memory: 3832kb

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: 0ms
memory: 3756kb

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: 0
Accepted
time: 5ms
memory: 3832kb

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:

-1

result:

ok 1 number(s): "-1"

Test #17:

score: 0
Accepted
time: 5ms
memory: 3824kb

input:

100000
97549 28518 59487 90456 21425 52394 83363 14332 45301 76270 7239 38208 69177 146 31115 62084 93053 24022 54991 85960 16929 47898 78867 9836 40805 71774 2743 33712 64681 95650 26619 57588 88557 19526 50495 81464 12433 43402 74371 5340 36309 67278 98247 29216 60185 91154 22123 53092 84061 15030...

output:

-1

result:

ok 1 number(s): "-1"

Test #18:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

32693
28792 854 5609 10364 15119 19874 24629 29384 1446 6201 10956 15711 20466 25221 29976 2038 6793 11548 16303 21058 25813 30568 2630 7385 12140 16895 21650 26405 31160 3222 7977 12732 17487 22242 26997 31752 3814 8569 13324 18079 22834 27589 32344 4406 9161 13916 18671 23426 28181 243 4998 9753 1...

output:

-1

result:

ok 1 number(s): "-1"

Test #19:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

24669
10943 1258 16242 6557 21541 11856 2171 17155 7470 22454 12769 3084 18068 8383 23367 13682 3997 18981 9296 24280 14595 4910 19894 10209 524 15508 5823 20807 11122 1437 16421 6736 21720 12035 2350 17334 7649 22633 12948 3263 18247 8562 23546 13861 4176 19160 9475 24459 14774 5089 20073 10388 703...

output:

-1

result:

ok 1 number(s): "-1"

Test #20:

score: 0
Accepted
time: 4ms
memory: 3756kb

input:

71728
25793 57433 17345 48985 8897 40537 449 32089 63729 23641 55281 15193 46833 6745 38385 70025 29937 61577 21489 53129 13041 44681 4593 36233 67873 27785 59425 19337 50977 10889 42529 2441 34081 65721 25633 57273 17185 48825 8737 40377 289 31929 63569 23481 55121 15033 46673 6585 38225 69865 2977...

output:

-1

result:

ok 1 number(s): "-1"

Test #21:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

14334
2156 2607 3058 3509 3960 4411 4862 5313 5764 6215 6666 7117 7568 8019 8470 8921 9372 9823 10274 10725 11176 11627 12078 12529 12980 13431 13882 14333 450 901 1352 1803 2254 2705 3156 3607 4058 4509 4960 5411 5862 6313 6764 7215 7666 8117 8568 9019 9470 9921 10372 10823 11274 11725 12176 12627 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

5968
1769 4754 1771 4756 1773 4758 1775 4760 1777 4762 1779 4764 1781 4766 1783 4768 1785 4770 1787 4772 1789 4774 1791 4776 1793 4778 1795 4780 1797 4782 1799 4784 1801 4786 1803 4788 1805 4790 1807 4792 1809 4794 1811 4796 1813 4798 1815 4800 1817 4802 1819 4804 1821 4806 1823 4808 1825 4810 1827 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #23:

score: 0
Accepted
time: 3ms
memory: 3816kb

input:

65536
0 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024 1088 1152 1216 1280 1344 1408 1472 1536 1600 1664 1728 1792 1856 1920 1984 2048 2112 2176 2240 2304 2368 2432 2496 2560 2624 2688 2752 2816 2880 2944 3008 3072 3136 3200 3264 3328 3392 3456 3520 3584 3648 3712 3776 3840 3904 396...

output:

-1

result:

ok 1 number(s): "-1"