CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Kyselyt
Sender:
Submission time:2015-12-20 13:45:53 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#3ACCEPTED63
Test results
testverdicttimegroup
#1ACCEPTED0.06 s1details
#2ACCEPTED0.06 s1details
#3ACCEPTED0.05 s1details
#4ACCEPTED0.06 s1details
#5ACCEPTED0.05 s1details
#6ACCEPTED0.08 s2details
#7ACCEPTED0.07 s2details
#8ACCEPTED0.07 s2details
#9ACCEPTED0.10 s2details
#10ACCEPTED0.07 s2details
#11ACCEPTED0.21 s3details
#12ACCEPTED0.21 s3details
#13ACCEPTED0.20 s3details
#14ACCEPTED0.20 s3details
#15ACCEPTED0.20 s3details

Code

#include <iostream>
using namespace std;
const int N = 1<<18;
int st1[2*N];
int st2[2*N];
int getMin(int a, int b) {
    a += N;
    b += N;
    int mi = 1e9;
    for(; a <= b; a/=2, b/=2) {
        if(a&1) mi = min(mi, st1[a++]);
        if(~b&1) mi = min(mi, st1[b--]);
    }
    return mi;
}
int getMax(int a, int b) {
    a += N;
    b += N;
    int ma = 0;
    for(; a <= b; a/=2, b/=2) {
        if(a&1) ma = max(ma, st2[a++]);
        if(~b&1) ma = max(ma, st2[b--]);
    }
    return ma;
}
void setValue(int a, int v) {
    a += N;
    st1[a] = st2[a] = v;
    for(a/=2; a; a/=2) {
        st1[a] = min(st1[a*2], st1[a*2+1]);
        st2[a] = max(st2[a*2], st2[a*2+1]);
    }
}
int main() {
    int n,q;
    cin>>n>>q;
    for(int i = 0; i< n; ++i) {
        cin>>st1[N+i];
        st2[N+i] = st1[N+i];
    }
    for(int a = N-1; a; --a) {
        st1[a] = min(st1[a*2], st1[a*2+1]);
        st2[a] = max(st2[a*2], st2[a*2+1]);
    }
    for(int i = 0; i < q; ++i) {
        char type;
        cin>>type;
        int a,b;
        cin>>a>>b;
        if(type == '!') {
            int a1 = st1[N+a-1];
            int b1 = st1[N+b-1];
            setValue(a-1, b1);
            setValue(b-1, a1);
        }
        else {
            if(b-a == getMax(a-1, b-1) - getMin(a-1, b-1)) {
                cout<<"10-4\n";
            }
            else {
                cout<<"QAQ\n";
            }
        }
    }
}

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
...