Task: | Kyselyt |
Sender: | |
Submission time: | 2015-12-20 13:57:11 +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.05 s | 1 | details |
#2 | ACCEPTED | 0.07 s | 1 | details |
#3 | ACCEPTED | 0.06 s | 1 | details |
#4 | ACCEPTED | 0.05 s | 1 | details |
#5 | ACCEPTED | 0.06 s | 1 | details |
#6 | ACCEPTED | 0.05 s | 2 | details |
#7 | ACCEPTED | 0.05 s | 2 | details |
#8 | ACCEPTED | 0.06 s | 2 | details |
#9 | ACCEPTED | 0.06 s | 2 | details |
#10 | ACCEPTED | 0.06 s | 2 | details |
#11 | ACCEPTED | 0.10 s | 3 | details |
#12 | ACCEPTED | 0.09 s | 3 | details |
#13 | ACCEPTED | 0.09 s | 3 | details |
#14 | ACCEPTED | 0.10 s | 3 | details |
#15 | ACCEPTED | 0.10 s | 3 | details |
Code
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll N=1<<17; int miTr[2*N], maTr[2*N]; void ans(int k) { if (k) cout<<"10-4\n"; else cout<<"QAQ\n"; } void build() { for (int i=N-1;i>0;i--) { miTr[i]=min(miTr[2*i],miTr[2*i+1]); maTr[i]=max(maTr[2*i],maTr[2*i+1]); } } void upd(int ind, int val) { ind+=N; miTr[ind]=val; maTr[ind]=val; for (ind/=2;ind>0;ind/=2) { miTr[ind]=min(miTr[2*ind],miTr[2*ind+1]); maTr[ind]=max(maTr[2*ind],maTr[2*ind+1]); } } void vaihto(int a, int b) { a--; b--; int k1=miTr[a+N]; int k2=miTr[b+N]; upd(a,k2); upd(b,k1); } int askMin(int a, int b) { a+=N; b+=N; int res =N; while (a<=b) { if (a%2==1) res=min(res,miTr[a++]); if (b%2==0) res=min(res,miTr[b--]); a/=2; b/=2; } return res; } int askMax(int a, int b) { a+=N; b+=N; int res =0; while (a<=b) { if (a%2==1) res=max(res,maTr[a++]); if (b%2==0) res=max(res,maTr[b--]); a/=2; b/=2; } return res; } void kaunis(int a, int b) { a--; b--; ans(askMax(a,b)-askMin(a,b)==b-a); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,q; cin>>n>>q; for (int i=0;i<n;i++) { cin>>miTr[N+i]; maTr[N+i]=miTr[N+i]; } build(); for (int i=0;i<q;i++) { string s; int a,b; cin>>s>>a>>b; if (s[0]=='!') vaihto(a,b); else kaunis(a,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 ... |