CSES - Aalto Competitive Programming 2024 - wk5 - Mon - Results
Submission details
Task:Pukkitappelu battle royale
Sender:aalto2024e_003
Submission time:2024-09-30 17:54:13 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#11ACCEPTED0.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails
#150.00 sdetails
#160.00 sdetails
#170.00 sdetails
#18ACCEPTED0.00 sdetails
#190.00 sdetails
#200.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#250.00 sdetails
#260.00 sdetails
#270.00 sdetails
#28ACCEPTED0.00 sdetails
#290.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#320.00 sdetails
#33ACCEPTED0.00 sdetails
#340.00 sdetails
#350.00 sdetails
#36ACCEPTED0.00 sdetails
#370.00 sdetails
#380.00 sdetails
#390.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#420.00 sdetails
#43ACCEPTED0.00 sdetails
#440.00 sdetails
#450.00 sdetails
#46ACCEPTED0.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#50ACCEPTED0.00 sdetails
#510.00 sdetails
#520.00 sdetails
#530.00 sdetails
#540.00 sdetails
#550.00 sdetails
#560.00 sdetails
#57ACCEPTED0.00 sdetails
#58ACCEPTED0.00 sdetails
#59ACCEPTED0.00 sdetails
#60ACCEPTED0.00 sdetails
#610.00 sdetails
#62ACCEPTED0.00 sdetails
#630.00 sdetails
#64ACCEPTED0.00 sdetails
#65ACCEPTED0.00 sdetails
#66ACCEPTED0.00 sdetails
#67ACCEPTED0.00 sdetails
#68ACCEPTED0.00 sdetails
#69ACCEPTED0.00 sdetails
#700.00 sdetails
#71ACCEPTED0.00 sdetails
#72ACCEPTED0.00 sdetails
#730.00 sdetails
#74ACCEPTED0.00 sdetails
#750.00 sdetails
#76ACCEPTED0.00 sdetails
#770.00 sdetails
#78ACCEPTED0.00 sdetails
#79ACCEPTED0.00 sdetails
#800.06 sdetails
#81ACCEPTED0.05 sdetails
#82ACCEPTED0.05 sdetails
#830.05 sdetails
#840.05 sdetails
#85ACCEPTED0.05 sdetails
#860.05 sdetails
#87ACCEPTED0.04 sdetails
#88ACCEPTED0.05 sdetails
#890.04 sdetails

Code

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    long long x;
    cin >> n >> x;
    vector<long long> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    
    vector<bool> alive(n, true);
    
    // Eliminate initially blocked players
    for(int i=0; i<n; ++i){
        bool left_blocked = (i==0 && a[i]==1) || (i>0 && a[i-1]+1==a[i]);
        bool right_blocked = (i==n-1 && a[i]==x) || (i<n-1 && a[i]+1==a[i+1]);
        if(left_blocked && right_blocked){
            alive[i] = false;
        }
    }
    
    // Find the last remaining player
    int winner = -1;
    for(int i=n-1; i>=0; --i){
        if(alive[i]){
            winner = i+1;
            break;
        }
    }
    cout << winner << endl;
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1 14
10 

correct output
1

user output
1

Test 2

Verdict: ACCEPTED

input
2 10
1 2 

correct output
2

user output
2

Test 3

Verdict:

input
2 7
3 5 

correct output
1

user output
2

Test 4

Verdict:

input
2 13
4 12 

correct output
1

user output
2

Test 5

Verdict:

input
2 12
6 10 

correct output
1

user output
2

Test 6

Verdict: ACCEPTED

input
2 6
3 6 

correct output
2

user output
2

Test 7

Verdict: ACCEPTED

input
2 19
6 15 

correct output
2

user output
2

Test 8

Verdict:

input
2 16
2 14 

correct output
1

user output
2

Test 9

Verdict:

input
2 20
11 13 

correct output
1

user output
2

Test 10

Verdict:

input
2 17
7 15 

correct output
1

user output
2

Test 11

Verdict: ACCEPTED

input
2 18
7 18 

correct output
2

user output
2

Test 12

Verdict:

input
3 8
1 6 8 

correct output
2

user output
3

Test 13

Verdict:

input
3 20
11 13 15 

correct output
1

user output
3

Test 14

Verdict:

input
3 8
3 6 8 

correct output
2

user output
3

Test 15

Verdict:

input
3 14
5 8 10 

correct output
2

user output
3

Test 16

Verdict:

input
3 3
1 2 3 

correct output
3

user output
-1

Test 17

Verdict:

input
3 7
1 6 7 

correct output
3

user output
2

Test 18

Verdict: ACCEPTED

input
3 12
3 10 11 

correct output
3

user output
3

Test 19

Verdict:

input
3 3
1 2 3 

correct output
3

user output
-1

Test 20

Verdict:

input
3 3
1 2 3 

correct output
3

user output
-1

Test 21

Verdict: ACCEPTED

input
3 15
1 4 5 

correct output
3

user output
3

Test 22

Verdict: ACCEPTED

input
3 10
6 8 9 

correct output
3

user output
3

Test 23

Verdict: ACCEPTED

input
3 13
8 9 12 

correct output
3

user output
3

Test 24

Verdict: ACCEPTED

input
4 20
2 8 13 14 

correct output
4

user output
4

Test 25

Verdict:

input
4 20
12 13 14 18 

correct output
3

user output
4

Test 26

Verdict:

input
4 13
2 4 12 13 

correct output
4

user output
3

Test 27

Verdict:

input
4 13
1 3 7 13 

correct output
1

user output
4

Test 28

Verdict: ACCEPTED

input
4 16
5 7 8 15 

correct output
4

user output
4

Test 29

Verdict:

input
4 11
7 8 10 11 

correct output
4

user output
3

Test 30

Verdict: ACCEPTED

input
5 13
6 8 10 11 12 

correct output
5

user output
5

Test 31

Verdict: ACCEPTED

input
5 11
1 2 4 8 11 

correct output
5

user output
5

Test 32

Verdict:

input
5 11
1 3 5 7 11 

correct output
1

user output
5

Test 33

Verdict: ACCEPTED

input
5 13
1 2 4 10 11 

correct output
5

user output
5

Test 34

Verdict:

input
5 20
4 11 18 19 20 

correct output
5

user output
3

Test 35

Verdict:

input
5 8
1 2 3 7 8 

correct output
5

user output
4

Test 36

Verdict: ACCEPTED

input
5 19
2 4 7 16 19 

correct output
5

user output
5

Test 37

Verdict:

input
5 6
2 3 4 5 6 

correct output
5

user output
1

Test 38

Verdict:

input
5 18
1 5 7 16 18 

correct output
4

user output
5

Test 39

Verdict:

input
5 5
1 2 3 4 5 

correct output
5

user output
-1

Test 40

Verdict: ACCEPTED

input
10 16
1 5 7 8 9 10 11 12 14 15 

correct output
10

user output
10

Test 41

Verdict: ACCEPTED

input
10 14
1 2 3 4 5 6 8 10 11 14 

correct output
10

user output
10

Test 42

Verdict:

input
10 14
1 2 3 5 6 7 8 9 10 14 

correct output
9

user output
10

Test 43

Verdict: ACCEPTED

input
10 16
1 2 3 5 7 9 10 12 14 15 

correct output
10

user output
10

Test 44

Verdict:

input
10 20
4 5 11 12 13 14 15 18 19 20 

correct output
10

user output
8

Test 45

Verdict:

input
10 12
1 2 3 5 6 7 8 10 11 12 

correct output
10

user output
8

Test 46

Verdict: ACCEPTED

input
10 19
1 2 3 4 7 8 11 12 16 19 

correct output
10

user output
10

Test 47

Verdict:

input
10 10
1 2 3 4 5 6 7 8 9 10 

correct output
10

user output
-1

Test 48

Verdict:

input
10 19
1 5 8 9 11 12 15 16 17 19 

correct output
9

user output
10

Test 49

Verdict:

input
10 10
1 2 3 4 5 6 7 8 9 10 

correct output
10

user output
-1

Test 50

Verdict: ACCEPTED

input
100 589284111
11528796 12405338 23576564 347...

correct output
100

user output
100

Test 51

Verdict:

input
100 447774061
54585 8727508 9242273 13069870...

correct output
98

user output
100

Test 52

Verdict:

input
100 468146062
12372478 31155934 38008300 391...

correct output
99

user output
100

Test 53

Verdict:

input
100 591414846
11503156 12648374 14184172 147...

correct output
94

user output
100

Test 54

Verdict:

input
100 967035023
5539596 6689688 9648746 204276...

correct output
92

user output
100

Test 55

Verdict:

input
100 238363452
391838 528333 1368439 3479103 ...

correct output
95

user output
100

Test 56

Verdict:

input
100 958701382
44771412 58491554 63972355 689...

correct output
97

user output
100

Test 57

Verdict: ACCEPTED

input
100 81935503
1314125 2056565 5446047 595110...

correct output
100

user output
100

Test 58

Verdict: ACCEPTED

input
100 937837780
11934038 12239373 22850648 308...

correct output
100

user output
100

Test 59

Verdict: ACCEPTED

input
100 11139267
84150 148618 432268 440149 520...

correct output
100

user output
100

Test 60

Verdict: ACCEPTED

input
200 589284211
2880992 5740962 8327109 115287...

correct output
200

user output
200

Test 61

Verdict:

input
200 447774161
54585 1369773 4298783 5568757 ...

correct output
199

user output
200

Test 62

Verdict: ACCEPTED

input
200 468146162
2645901 6212116 12193387 12372...

correct output
200

user output
200

Test 63

Verdict:

input
200 591414946
11503156 12648374 13023409 141...

correct output
197

user output
200

Test 64

Verdict: ACCEPTED

input
200 967035123
3142409 4210032 5539596 668968...

correct output
200

user output
200

Test 65

Verdict: ACCEPTED

input
200 238363552
391838 528333 1368439 2951457 ...

correct output
200

user output
200

Test 66

Verdict: ACCEPTED

input
200 958701482
915344 26318971 39308105 44426...

correct output
200

user output
200

Test 67

Verdict: ACCEPTED

input
200 81935603
117854 1314125 2056565 3274591...

correct output
200

user output
200

Test 68

Verdict: ACCEPTED

input
200 937837880
798751 8921056 9526547 1193403...

correct output
200

user output
200

Test 69

Verdict: ACCEPTED

input
200 11139367
50914 81279 84150 90865 148618...

correct output
200

user output
200

Test 70

Verdict:

input
1000 589285011
33962 2483784 2880992 4837424 ...

correct output
998

user output
1000

Test 71

Verdict: ACCEPTED

input
1000 447774961
54585 191853 483557 1369773 14...

correct output
1000

user output
1000

Test 72

Verdict: ACCEPTED

input
1000 468146962
58977 735268 898440 1184659 12...

correct output
1000

user output
1000

Test 73

Verdict:

input
1000 591415746
293786 457427 1304174 2617747 ...

correct output
995

user output
1000

Test 74

Verdict: ACCEPTED

input
1000 967035923
838480 973536 1455856 3142409 ...

correct output
1000

user output
1000

Test 75

Verdict:

input
1000 238364352
91364 391838 528333 959636 117...

correct output
998

user output
1000

Test 76

Verdict: ACCEPTED

input
1000 958702282
557448 915344 2438616 2817236 ...

correct output
1000

user output
1000

Test 77

Verdict:

input
1000 81936403
117854 134799 153186 216760 34...

correct output
999

user output
1000

Test 78

Verdict: ACCEPTED

input
1000 937838680
798751 996213 1265361 2336515 ...

correct output
1000

user output
1000

Test 79

Verdict: ACCEPTED

input
1000 11140167
3811 29493 33378 46013 50914 5...

correct output
1000

user output
1000

Test 80

Verdict:

input
100000 589384011
2462 12290 14854 19988 28400 3...

correct output
99996

user output
100000

Test 81

Verdict: ACCEPTED

input
100000 447873961
324 4948 5149 18319 22491 2468...

correct output
100000

user output
100000

Test 82

Verdict: ACCEPTED

input
100000 468245962
9543 11563 11899 20558 24392 2...

correct output
100000

user output
100000

Test 83

Verdict:

input
100000 591514746
7688 9041 14326 23056 27308 28...

correct output
99998

user output
100000

Test 84

Verdict:

input
100000 967134923
1024 2994 6645 24256 27426 329...

correct output
99997

user output
100000

Test 85

Verdict: ACCEPTED

input
100000 238463352
675 900 4012 15115 15476 22069...

correct output
100000

user output
100000

Test 86

Verdict:

input
100000 958801282
7177 18494 20083 35163 36876 4...

correct output
99999

user output
100000

Test 87

Verdict: ACCEPTED

input
100000 82035403
237 539 626 1804 2747 3269 358...

correct output
100000

user output
100000

Test 88

Verdict: ACCEPTED

input
100000 937937680
1191 7701 13173 20679 24337 30...

correct output
100000

user output
100000

Test 89

Verdict:

input
100000 11239167
70 124 318 547 595 692 784 880...

correct output
99999

user output
100000