CSES - Datatähti Open 2021 - Results
Submission details
Task:Split in Three
Sender:flash_0408
Submission time:2021-01-31 17:13:23 +0200
Language:C++ (C++17)
Status:READY
Result:22
Feedback
groupverdictscore
#1ACCEPTED22
#20
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s1, 2details
#3ACCEPTED0.01 s1, 2details
#4ACCEPTED0.01 s1, 2details
#5ACCEPTED0.01 s1, 2details
#6ACCEPTED0.01 s1, 2details
#7ACCEPTED0.01 s1, 2details
#8ACCEPTED0.01 s1, 2details
#90.01 s2details
#100.01 s2details
#110.01 s2details
#12ACCEPTED0.01 s2details
#130.01 s2details
#140.01 s2details
#15ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	int n;
	cin >> n; 

	if((n*(n+1)/2) % 3){
		cout << "IMPOSSIBLE\n"; 
		return 0; 
	}
	int sum = (n*(n+1))/2; 
	for(int mask1 = 0; mask1 < (1 << n); mask1++){
		for(int mask2 = 0; mask2 < (1 << n); mask2++){
			if(mask1 & mask2)
				continue; 
			int sum1 = 0, sum2 = 0; 
			for(int i = 0; i < n; i++){
				if(mask1 & (1 << i))
					sum1 += i+1; 
				if(mask2 & (1 << i))
					sum2 += i+1; 
			}

			if(sum1 + 1 == sum2 && sum - sum1 - sum2 == sum2 + 1){
				vector<int> ans(n); 

				for(int i = 0; i < n; i++){
					if(mask1 & (1 << i))
						ans[i] = 1; 
					else if(mask2 & (1 << i))
						ans[i] = 2;
					else ans[i] = 3; 
				}

				for(int v : ans)
					cout << v << ' '; 

				return 0; 
			}
		}
	}
	return 0; 
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
3

correct output
1 2 3 

user output
1 2 3 

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 3

Group: 1, 2

Verdict: ACCEPTED

input
5

correct output
1 3 1 3 2 

user output
1 3 1 3 2 

Test 4

Group: 1, 2

Verdict: ACCEPTED

input
6

correct output
1 3 2 2 1 3 

user output
2 1 3 1 3 2 

Test 5

Group: 1, 2

Verdict: ACCEPTED

input
7

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 6

Group: 1, 2

Verdict: ACCEPTED

input
8

correct output
2 3 1 2 3 3 2 1 

user output
1 1 1 2 1 3 3 2 

Test 7

Group: 1, 2

Verdict: ACCEPTED

input
9

correct output
1 2 3 1 2 3 3 2 1 

user output
2 1 1 1 1 2 3 2 3 

Test 8

Group: 1, 2

Verdict: ACCEPTED

input
10

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 9

Group: 2

Verdict:

input
42

correct output
1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ...

user output
(empty)

Test 10

Group: 2

Verdict:

input
95

correct output
1 3 1 3 2 1 2 3 3 2 1 1 2 3 3 ...

user output
(empty)

Test 11

Group: 2

Verdict:

input
96

correct output
1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ...

user output
(empty)

Test 12

Group: 2

Verdict: ACCEPTED

input
97

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 13

Group: 2

Verdict:

input
98

correct output
2 3 1 2 3 3 2 1 1 2 3 3 2 1 1 ...

user output
(empty)

Test 14

Group: 2

Verdict:

input
99

correct output
1 2 3 1 2 3 3 2 1 1 2 3 3 2 1 ...

user output
(empty)

Test 15

Group: 2

Verdict: ACCEPTED

input
100

correct output
IMPOSSIBLE

user output
IMPOSSIBLE