Task: | Simple game |
Sender: | Lieska |
Submission time: | 2019-02-09 12:46:26 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 3 | details |
#2 | WRONG ANSWER | 0.02 s | 1, 3 | details |
#3 | WRONG ANSWER | 0.03 s | 1, 3 | details |
#4 | WRONG ANSWER | 0.02 s | 1, 3 | details |
#5 | WRONG ANSWER | 0.02 s | 1, 3 | details |
#6 | WRONG ANSWER | 0.03 s | 1, 3 | details |
#7 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#8 | ACCEPTED | 0.18 s | 2, 3 | details |
#9 | WRONG ANSWER | 0.23 s | 2, 3 | details |
#10 | WRONG ANSWER | 0.23 s | 2, 3 | details |
#11 | ACCEPTED | 0.17 s | 2, 3 | details |
#12 | ACCEPTED | 0.21 s | 2, 3 | details |
#13 | WRONG ANSWER | 0.22 s | 3 | details |
#14 | WRONG ANSWER | 0.22 s | 3 | details |
#15 | WRONG ANSWER | 0.23 s | 3 | details |
#16 | WRONG ANSWER | 0.23 s | 3 | details |
#17 | WRONG ANSWER | 0.22 s | 3 | details |
#18 | WRONG ANSWER | 0.23 s | 2, 3 | details |
Code
#include <bits/stdc++.h> using namespace std; int c, d, e, n, m, k=1; int t[1024*2049]={}, r[100001]={}; void muutos2(int f){ f+=k; while (f>0){ f/=2; t[f]=t[2*f]+t[2*f+1]; } } void muutos(int a, int b){ if (a>1 && abs(r[a]-r[a-1])>1){ if (r[a]>r[a-1]){ t[r[a-1]+1+k]--; t[r[a]+k]++; muutos2(r[a-1]+1); muutos2(r[a]); } else { t[r[a]+k+1]--; t[r[a-1]+k]++; muutos2(r[a]+1); muutos2(r[a-1]); } } if (a<n && abs(r[a+1]-r[a])>1){ if (r[a+1]>r[a]){ t[r[a]+k+1]--; t[r[a+1]+k]++; muutos2(r[a]+1); muutos2(r[a+1]); } else { t[r[a+1]+k+1]--; t[r[a]+k]++; muutos2(r[a+1]+1); muutos2(r[a]); } } r[a]=b; if (a>1 && abs(r[a]-r[a-1])>1){ if (r[a]>r[a-1]){ t[r[a-1]+k+1]++; t[r[a]+k]--; muutos2(r[a-1]+1); muutos2(r[a]); } else { t[r[a]+k+1]++; t[r[a-1]+k]--; muutos2(r[a]+1); muutos2(r[a-1]); } } if (a<n && abs(r[a+1]-r[a])>1){ if (r[a+1]>r[a]){ t[r[a]+k+1]++; t[r[a+1]+k]--; muutos2(r[a]+1); muutos2(r[a+1]); } else { t[r[a+1]+k+1]++; t[r[a]+k]--; muutos2(r[a+1]+1); muutos2(r[a]); } } } int summa(int g){ int s=0; while (g>0){ if (g%2==0){ s+=t[g]; g--; } g/=2; } return s; } int main(){ cin >> n >> m; k=8; while (k<=(n+1)/2) k*=2; for (int i=1; i<=n; ++i) cin >> r[i]; for (int i=2; i<=n; ++i){ if (abs(r[i]-r[i-1])>1){ if (r[i]>r[i-1]){ t[r[i-1]+1+k]++; t[r[i]+k]--; } else { t[r[i]+1+k]++; t[r[i-1]+k]--; } } } for (int i=k-1; i>0; --i) { t[i]=t[2*i]+t[2*i+1]; } for (int i=0; i<m; ++i){ cin >> c; if (c==1) { cin >> d >> e; muutos(d, e); } else { cin >> d; cout << summa(d+k) << "\n"; } } return 0; }
Test details
Test 1
Group: 1, 3
Verdict: ACCEPTED
input |
---|
3 3 1 5 1 2 3 1 1 5 2 3 |
correct output |
---|
2 1 |
user output |
---|
2 1 |
Test 2
Group: 1, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 403944 539844 451514 488113 69... |
correct output |
---|
444 462 34 516 288 ... |
user output |
---|
2 4 3 1 3 ... Truncated |
Test 3
Group: 1, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 487368 55984 456259 117591 818... |
correct output |
---|
440 400 480 130 38 ... |
user output |
---|
0 0 4 4 6 ... Truncated |
Test 4
Group: 1, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 570792 604828 236813 971260 13... |
correct output |
---|
386 460 50 470 126 ... |
user output |
---|
0 1 2 2 -2 ... Truncated |
Test 5
Group: 1, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 686920 120969 241559 600738 48... |
correct output |
---|
330 306 418 290 136 ... |
user output |
---|
0 -2 2 2 -1 ... Truncated |
Test 6
Group: 1, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 737640 478325 54816 262919 609... |
correct output |
---|
230 418 148 338 4 ... |
user output |
---|
0 0 0 2 4 ... Truncated |
Test 7
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1000 1000 1 1000000 1 1000000 1 1000000 ... |
correct output |
---|
999 999 999 999 999 ... |
user output |
---|
999 999 999 999 999 ... Truncated |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100000 100000 18 15 8 5 7 19 19 11 11 8 6 15... |
correct output |
---|
0 0 0 0 0 ... |
user output |
---|
0 0 0 0 0 ... Truncated |
Test 9
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 611680 625326 848926 304761 34... |
correct output |
---|
30636 30745 50130 4464 9086 ... |
user output |
---|
11774 8476 1032 4464 11658 ... Truncated |
Test 10
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 695104 174171 853672 901534 35... |
correct output |
---|
31870 39772 30788 11144 42732 ... |
user output |
---|
24 3950 8604 11410 5982 ... Truncated |
Test 11
Group: 2, 3
Verdict: ACCEPTED
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 |
---|
0 0 0 0 0 ... Truncated |
Test 12
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100000 100000 2845 22894 4105 11830 29440 21... |
correct output |
---|
45066 50090 24109 27778 294 ... |
user output |
---|
45066 50090 24109 27778 294 ... Truncated |
Test 13
Group: 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 123269 247698 241557 639404 38... |
correct output |
---|
37412 1520 46224 964 50058 ... |
user output |
---|
7056 1520 4340 156 852 ... Truncated |
Test 14
Group: 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 206693 572351 22110 493074 737... |
correct output |
---|
33086 49042 43971 17756 41889 ... |
user output |
---|
8004 2684 6320 10456 5057 ... Truncated |
Test 15
Group: 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 322821 121195 59560 155256 829... |
correct output |
---|
28252 45031 28212 6208 31642 ... |
user output |
---|
8786 7246 10074 6207 8169 ... Truncated |
Test 16
Group: 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 438949 637336 872818 784733 17... |
correct output |
---|
45374 22320 9690 5630 40012 ... |
user output |
---|
4526 5937 9694 11812 6134 ... Truncated |
Test 17
Group: 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 489669 186180 653371 446915 52... |
correct output |
---|
43104 43128 41430 35554 996 ... |
user output |
---|
5510 5509 6039 1677 1004 ... Truncated |
Test 18
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
100000 100000 1 1000000 1 1000000 1 1000000 ... |
correct output |
---|
99999 99999 99999 99999 99999 ... |
user output |
---|
99999 99999 99999 99999 99999 ... Truncated |