Submission details
Task:Mascot Song
Sender:Nanohenry
Submission time:2018-07-23 17:27:45 +0300
Language:C++
Status:READY
Result:60
Feedback
groupverdictscore
#1ACCEPTED30
#2ACCEPTED30
#30
Test results
testverdicttimegroup
#1ACCEPTED0.02 s1details
#2ACCEPTED0.02 s1details
#3ACCEPTED0.02 s1details
#4ACCEPTED0.24 s2details
#5ACCEPTED0.28 s2details
#6ACCEPTED0.24 s2details
#7--3details
#8--3details
#9--3details
#10--3details

Code

#include <iostream>
#include <valarray>

using namespace std;

long n, q, c;
valarray<long> v;

long getBlocks(bool t, long j, long e) {
	if (!t) {
		long r = 1, p = 0;
		for (long i = 0; i < n; i++) {
			if (p >= v[i])
				r++;
			p = v[i];
		}
		c = r;
		return r;
	} else {
		if (j > 0 && v[j - 1] < e && v[j - 1] >= v[j]) {
			c++;
		}
		if (j > 0 && v[j - 1] >= e && v[j - 1] < v[j]) {
			c--;
		}
		if (j < n && v[j + 1] > e && v[j + 1] <= v[j]) {
			c++;
		}
		if (j < n && v[j + 1] <= e && v[j + 1] > v[j]) {
			c--;
		}
		return c;
	}
}

int main() {
	cin >> n;
	v.resize(n);
	for (long i = 0; i < n; i++) {
		cin >> v[i];
	}
	getBlocks(0, 0, 0);
	cin >> q;
	for (long i = 0; i < q; i++) {
		long a, b, c;
		cin >> a;
		if (a == 1) {
			cin >> b >> c;
			long g = v[b - 1];
			v[b - 1] = c;
			cout << getBlocks(1, b - 1, g) << '\n';
		} else {
			cin >> b;
			v = v.cshift(b);
			cout << getBlocks(0, 0, 0) << '\n';
		}
	}
	//system("pause");
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
10
4 5 6 1 10 20 15 16 17 1
13
1 10 2
2 9
...

correct output
4
3
4
4
4
...

user output
4
3
4
4
4
...

Test 2

Group: 1

Verdict: ACCEPTED

input
30
18 48 48 7 60 21 11 49 14 10 1...

correct output
16
17
17
17
16
...

user output
16
17
17
17
16
...

Test 3

Group: 1

Verdict: ACCEPTED

input
100
11 16 18 16 14 7 6 1 22 8 19 5...

correct output
50
50
50
50
49
...

user output
50
50
50
50
49
...

Test 4

Group: 2

Verdict: ACCEPTED

input
80000
581256238 412911089 468450337 ...

correct output
39831
39830
39830
39830
39831
...

user output
39831
39830
39830
39830
39831
...

Test 5

Group: 2

Verdict: ACCEPTED

input
150000
2013 2014 2014 2014 2014 2014 ...

correct output
150000
149999
149998
149997
149996
...

user output
150000
149999
149998
149997
149996
...

Test 6

Group: 2

Verdict: ACCEPTED

input
190000
62 4981 98 3407 7210 6339 1348...

correct output
94991
94991
94991
94992
94992
...

user output
94991
94991
94991
94992
94992
...

Test 7

Group: 3

Verdict:

input
50000
446 494 191 356 886 78 470 223...

correct output
24959
24959
24960
24960
24960
...

user output
(empty)

Test 8

Group: 3

Verdict:

input
170333
1 1001 2001 3001 4001 5001 600...

correct output
2
3
3
3
4
...

user output
(empty)

Test 9

Group: 3

Verdict:

input
200000
571574128 419362929 843317486 ...

correct output
100061
100061
100061
100060
100060
...

user output
(empty)

Test 10

Group: 3

Verdict:

input
200000
262656227 860259516 849559109 ...

correct output
99946
99946
99947
99947
99947
...

user output
(empty)