CSES - IZhO 2017, day 2 - Results
Submission details
Task:Simple game
Sender:Jaahas
Submission time:2019-02-09 13:24:43 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.02 s1, 3details
#20.02 s1, 3details
#30.02 s1, 3details
#40.01 s1, 3details
#50.01 s1, 3details
#60.01 s1, 3details
#70.01 s1, 2, 3details
#80.03 s2, 3details
#90.02 s2, 3details
#100.03 s2, 3details
#110.03 s2, 3details
#120.02 s2, 3details
#130.02 s3details
#140.02 s3details
#150.02 s3details
#160.02 s3details
#170.03 s3details
#180.02 s2, 3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:4:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("game.in", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:5:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("game.out", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
int main() {
    freopen("game.in", "r", stdin);
    freopen("game.out", "w", stdout);
    
//    cin.tie(0);
//    ios_base::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;
    vector<int> v;
    for(int i=0; i<n; i++) {
        int h;
        cin >> h;
        v.push_back(h);
    }

    for(int i=0; i<m; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            int pos, val;
            cin >> pos >> val;
            v[pos-1] = val;
        } else {
            int h;
            cin >> h;
            int c = 0;
            for(int j=0; j<n-1; j++) {
                if((v[j] < h && v[j+1] > h) || (v[j] > h && v[j+1] < h))
                    c++;
            }
            cout << c << '\n';
        }
    }
}

Test details

Test 1

Group: 1, 3

Verdict:

input
3 3
1 5 1
2 3
1 1 5
2 3

correct output
2
1

user output
(empty)

Test 2

Group: 1, 3

Verdict:

input
1000 1000
403944 539844 451514 488113 69...

correct output
444
462
34
516
288
...

user output
(empty)

Test 3

Group: 1, 3

Verdict:

input
1000 1000
487368 55984 456259 117591 818...

correct output
440
400
480
130
38
...

user output
(empty)

Test 4

Group: 1, 3

Verdict:

input
1000 1000
570792 604828 236813 971260 13...

correct output
386
460
50
470
126
...

user output
(empty)

Test 5

Group: 1, 3

Verdict:

input
1000 1000
686920 120969 241559 600738 48...

correct output
330
306
418
290
136
...

user output
(empty)

Test 6

Group: 1, 3

Verdict:

input
1000 1000
737640 478325 54816 262919 609...

correct output
230
418
148
338
4
...

user output
(empty)

Test 7

Group: 1, 2, 3

Verdict:

input
1000 1000
1 1000000 1 1000000 1 1000000 ...

correct output
999
999
999
999
999
...

user output
(empty)

Test 8

Group: 2, 3

Verdict:

input
100000 100000
18 15 8 5 7 19 19 11 11 8 6 15...

correct output
0
0
0
0
0
...

user output
(empty)

Test 9

Group: 2, 3

Verdict:

input
100000 100000
611680 625326 848926 304761 34...

correct output
30636
30745
50130
4464
9086
...

user output
(empty)

Test 10

Group: 2, 3

Verdict:

input
100000 100000
695104 174171 853672 901534 35...

correct output
31870
39772
30788
11144
42732
...

user output
(empty)

Test 11

Group: 2, 3

Verdict:

input
100000 100000
1 1 1 2 1 1 2 1 2 2 1 2 2 1 1 ...

correct output
0
0
0
0
0
...

user output
(empty)

Test 12

Group: 2, 3

Verdict:

input
100000 100000
2845 22894 4105 11830 29440 21...

correct output
45066
50090
24109
27778
294
...

user output
(empty)

Test 13

Group: 3

Verdict:

input
100000 100000
123269 247698 241557 639404 38...

correct output
37412
1520
46224
964
50058
...

user output
(empty)

Test 14

Group: 3

Verdict:

input
100000 100000
206693 572351 22110 493074 737...

correct output
33086
49042
43971
17756
41889
...

user output
(empty)

Test 15

Group: 3

Verdict:

input
100000 100000
322821 121195 59560 155256 829...

correct output
28252
45031
28212
6208
31642
...

user output
(empty)

Test 16

Group: 3

Verdict:

input
100000 100000
438949 637336 872818 784733 17...

correct output
45374
22320
9690
5630
40012
...

user output
(empty)

Test 17

Group: 3

Verdict:

input
100000 100000
489669 186180 653371 446915 52...

correct output
43104
43128
41430
35554
996
...

user output
(empty)

Test 18

Group: 2, 3

Verdict:

input
100000 100000
1 1000000 1 1000000 1 1000000 ...

correct output
99999
99999
99999
99999
99999
...

user output
(empty)