CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Turnaus
Sender:
Submission time:2015-12-20 13:51:44 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED19
#2ACCEPTED42
#3ACCEPTED39
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.06 s1details
#3ACCEPTED0.05 s1details
#4ACCEPTED0.05 s1details
#5ACCEPTED0.05 s1details
#6ACCEPTED0.05 s2details
#7ACCEPTED0.05 s2details
#8ACCEPTED0.06 s2details
#9ACCEPTED0.05 s2details
#10ACCEPTED0.06 s2details
#11ACCEPTED0.05 s3details
#12ACCEPTED0.05 s3details
#13ACCEPTED0.05 s3details
#14ACCEPTED0.05 s3details
#15ACCEPTED0.05 s3details
#16ACCEPTED0.16 s3details
#17ACCEPTED0.16 s3details
#18ACCEPTED0.16 s3details
#19ACCEPTED0.16 s3details
#20ACCEPTED0.06 s3details

Code

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<pair<int, int> > v;
	set<pair<int, int> > lol;
	int s=0;
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		int x;
		cin>>x;
		lol.insert({-x, i});
		if (x>=n){
			cout<<"QAQ"<<endl;
			return 0;
		}
		s+=x;
	}
	if (s%2==1){
		cout<<"QAQ"<<endl;
		return 0;
	}
	while (1){
		if ((*lol.begin()).F==0){
			break;
		}
		int tn=-(*lol.begin()).F;
		int f=0;
		//cout<<tn<<" "<<(*lol.begin()).S<<endl;
		vector<pair<int, int> > fo;
		for (auto asd:lol){
			if (tn==0) break;
			if (f==0){
				f=1;
			}
			else{
				if (asd.F==0){
					break;
				}
				fo.push_back(asd);
				tn--;
			}
		}
		if (tn>0){
			cout<<"QAQ"<<endl;
			return 0;
		}
		int tt=(*lol.begin()).S;
		lol.erase(lol.begin());
		for (auto ff:fo){
			//cout<<tt<<" u "<<ff.S<<endl;
			v.push_back({tt, ff.S});
			lol.erase(ff);
			lol.insert({ff.F+1, ff.S});
		}
	}
	cout<<v.size()<<endl;
	for (auto vv:v){
		cout<<vv.F<<" "<<vv.S<<endl;
	}
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
10
5 4 2 6 6 3 4 7 8 5

correct output
25
9 8
9 5
9 4
9 10
...

user output
25
9 8
9 4
9 5
9 1
...

Test 2

Group: 1

Verdict: ACCEPTED

input
10
6 4 4 6 5 6 1 2 1 7

correct output
21
10 6
10 4
10 1
10 5
...

user output
21
10 1
10 4
10 6
10 5
...

Test 3

Group: 1

Verdict: ACCEPTED

input
10
3 5 3 2 3 1 1 1 1 6

correct output
13
10 2
10 5
10 3
10 1
...

user output
13
10 2
10 1
10 3
10 5
...

Test 4

Group: 1

Verdict: ACCEPTED

input
10
4 4 4 6 3 5 7 1 5 9

correct output
24
10 7
10 4
10 9
10 6
...

user output
24
10 7
10 4
10 6
10 9
...

Test 5

Group: 1

Verdict: ACCEPTED

input
10
5 8 5 5 8 4 0 1 4 0

correct output
QAQ

user output
QAQ

Test 6

Group: 2

Verdict: ACCEPTED

input
100
57 62 69 61 64 62 56 58 61 58 ...

correct output
2850
96 89
96 100
96 91
96 68
...

user output
2850
89 96
89 100
89 68
89 91
...

Test 7

Group: 2

Verdict: ACCEPTED

input
100
52 56 50 52 63 53 56 65 47 55 ...

correct output
2813
97 100
97 77
97 75
97 89
...

user output
2813
97 100
97 77
97 75
97 89
...

Test 8

Group: 2

Verdict: ACCEPTED

input
100
52 58 46 54 55 51 48 49 53 45 ...

correct output
2421
90 97
90 78
90 61
90 94
...

user output
2421
90 97
90 78
90 61
90 67
...

Test 9

Group: 2

Verdict: ACCEPTED

input
100
53 44 41 54 34 44 44 51 42 38 ...

correct output
2145
99 87
99 88
99 93
99 82
...

user output
2145
99 87
99 88
99 82
99 93
...

Test 10

Group: 2

Verdict: ACCEPTED

input
100
51 2 34 17 16 53 56 37 11 94 4...

correct output
QAQ

user output
QAQ

Test 11

Group: 3

Verdict: ACCEPTED

input
100
49 55 47 49 57 47 59 52 51 52 ...

correct output
2674
96 87
96 80
96 89
96 74
...

user output
2674
96 87
96 80
96 57
96 74
...

Test 12

Group: 3

Verdict: ACCEPTED

input
100
44 49 47 50 46 45 46 43 45 53 ...

correct output
2361
100 96
100 88
100 99
100 81
...

user output
2361
100 96
100 88
100 99
100 81
...

Test 13

Group: 3

Verdict: ACCEPTED

input
100
55 50 46 47 48 54 59 51 50 43 ...

correct output
2318
92 85
92 71
92 53
92 56
...

user output
2318
92 85
92 71
92 53
92 56
...

Test 14

Group: 3

Verdict: ACCEPTED

input
100
45 51 47 56 47 51 47 55 57 41 ...

correct output
2464
87 84
87 89
87 73
87 88
...

user output
2464
87 84
87 89
87 73
87 76
...

Test 15

Group: 3

Verdict: ACCEPTED

input
100
40 95 88 91 27 5 93 69 46 50 7...

correct output
QAQ

user output
QAQ

Test 16

Group: 3

Verdict: ACCEPTED

input
100000
25 24 26 22 24 31 23 22 16 32 ...

correct output
100000
15 10
15 14
15 6
15 12
...

user output
100000
15 10
15 6
15 14
15 12
...

Test 17

Group: 3

Verdict: ACCEPTED

input
100000
27 24 25 26 18 32 26 19 21 19 ...

correct output
100000
6 66
6 37
6 16
6 62
...

user output
100000
6 66
6 16
6 37
6 62
...

Test 18

Group: 3

Verdict: ACCEPTED

input
100000
22 28 23 31 26 31 25 27 22 29 ...

correct output
100000
16 12
16 6
16 4
16 30
...

user output
100000
12 16
12 4
12 6
12 30
...

Test 19

Group: 3

Verdict: ACCEPTED

input
100000
19 26 25 24 25 29 20 23 30 22 ...

correct output
100000
9 27
9 6
9 207
9 156
...

user output
100000
9 6
9 27
9 13
9 18
...

Test 20

Group: 3

Verdict: ACCEPTED

input
100000
1 2 3 2 1 4 2 0 5 3 3 3 4 4 3 ...

correct output
QAQ

user output
QAQ