Task: | Kyselyt |
Sender: | |
Submission time: | 2015-12-20 14:05:25 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 25 |
#3 | ACCEPTED | 63 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.06 s | 1 | details |
#2 | ACCEPTED | 0.05 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.06 s | 1 | details |
#5 | ACCEPTED | 0.05 s | 1 | details |
#6 | ACCEPTED | 0.07 s | 2 | details |
#7 | ACCEPTED | 0.07 s | 2 | details |
#8 | ACCEPTED | 0.08 s | 2 | details |
#9 | ACCEPTED | 0.07 s | 2 | details |
#10 | ACCEPTED | 0.08 s | 2 | details |
#11 | ACCEPTED | 0.21 s | 3 | details |
#12 | ACCEPTED | 0.21 s | 3 | details |
#13 | ACCEPTED | 0.22 s | 3 | details |
#14 | ACCEPTED | 0.21 s | 3 | details |
#15 | ACCEPTED | 0.20 s | 3 | details |
Compiler report
input/code.cpp: In function 'int umn(int)': input/code.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ input/code.cpp: In function 'int umx(int)': input/code.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^
Code
#include <iostream>using namespace std;int n, q;#define SZ (1<<18)int sp_min[SZ];int sp_max[SZ];int mn(int a, int b){a+=SZ/2; b+=SZ/2;int rv=sp_min[a];while (a<b){if (a%2==1) rv=min(rv, sp_min[a++]);if (b%2==0) rv=min(rv, sp_min[b--]);a/=2; b/=2;}if (a==b) rv=min(rv, sp_min[a]);return rv;}int mx(int a, int b){a+=SZ/2; b+=SZ/2;int rv=sp_min[a];while (a<b){if (a%2==1) rv=max(rv, sp_max[a++]);if (b%2==0) rv=max(rv, sp_max[b--]);a/=2; b/=2;}if (a==b) rv=max(rv, sp_max[a]);return rv;}int umn(int a){a+=SZ/2;for (a/=2; a; a/=2) sp_min[a]=min(sp_min[2*a], sp_min[2*a+1]);}int umx(int a){a+=SZ/2;for (a/=2; a; a/=2) sp_max[a]=max(sp_max[2*a], sp_max[2*a+1]);}int main(){for (int i=0; i<SZ; ++i) sp_min[i]=1000000000;cin >> n >> q;for (int i=0; i<n; ++i){cin >> sp_min[i+SZ/2];sp_max[i+SZ/2]=sp_min[i+SZ/2];}for (int i=SZ/2-1; i; --i){sp_min[i]=min(sp_min[2*i], sp_min[2*i+1]);sp_max[i]=max(sp_max[2*i], sp_max[2*i+1]);}for (int i=0; i<q; ++i){char c; int a, b;cin >> c >> a >> b; --a; --b;if (a>b) swap(a, b);if (c=='?'){if (mx(a, b)-mn(a, b)==b-a){cout << "10-4\n";}else cout << "QAQ\n";}else{swap(sp_min[a+SZ/2], sp_min[b+SZ/2]);swap(sp_max[a+SZ/2], sp_max[b+SZ/2]);umn(a); umn(b);umx(a); umx(b);}}}
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
1000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
1000 1000 128 457 985 777 789 322 723 1 ... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
1000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
1000 1000 642 565 22 258 295 380 339 341... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
1000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
100000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
100000 1000 95033 30510 85695 94248 1652 9... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
100000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
100000 1000 93701 32360 85873 85418 5145 3... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
100000 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 QAQ ... |
user output |
---|
10-4 10-4 10-4 10-4 QAQ ... |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
100000 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
100000 100000 55896 749 62202 85583 19083 14... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
100000 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
user output |
---|
10-4 10-4 10-4 10-4 10-4 ... |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
100000 100000 96435 80769 7125 99626 45181 8... |
correct output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
user output |
---|
QAQ QAQ QAQ QAQ QAQ ... |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
100000 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
10-4 QAQ QAQ QAQ 10-4 ... |
user output |
---|
10-4 QAQ QAQ QAQ 10-4 ... |