Task: | Split in Three |
Sender: | knightron0 |
Submission time: | 2021-01-30 17:22:38 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 22 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 22 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.01 s | 1, 2 | details |
#4 | ACCEPTED | 0.01 s | 1, 2 | details |
#5 | ACCEPTED | 0.01 s | 1, 2 | details |
#6 | ACCEPTED | 0.01 s | 1, 2 | details |
#7 | ACCEPTED | 0.01 s | 1, 2 | details |
#8 | ACCEPTED | 0.01 s | 1, 2 | details |
#9 | WRONG ANSWER | 0.01 s | 2 | details |
#10 | WRONG ANSWER | 0.01 s | 2 | details |
#11 | WRONG ANSWER | 0.01 s | 2 | details |
#12 | ACCEPTED | 0.01 s | 2 | details |
#13 | WRONG ANSWER | 0.01 s | 2 | details |
#14 | WRONG ANSWER | 0.01 s | 2 | details |
#15 | ACCEPTED | 0.01 s | 2 | details |
Code
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) #define int long long int #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define float long double const int MOD = 1e9 + 7; const int INF = 2e15; const int MAXN = 1e5 + 5; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n; cin>>n; int sum = (n* (n+1))/2; sum -= 3; if(sum % 3 != 0){ cout<<"IMPOSSIBLE"<<endl; } else { int ans[n+1]; clr(ans, 0); int a= sum/3; int b = a+ 1; bool done = 0; if(a <= n && ans[a] == 0){ ans[a] = 1; } else { for(int i= 1;i<=n;i++){ if(ans[i] != 0) continue; for(int j= i+1;j<=n;j++){ if(ans[j] != 0) continue; if(i+j == a){ ans[i] = 1; ans[j] = 1; done = 1; break; } } if(done) break; } } done = 0; if(b <= n && ans[b] == 0){ ans[b] = 2; } else { for(int i= 1;i<=n;i++){ if(ans[i] != 0) continue; for(int j= i+1;j<=n;j++){ if(ans[j] != 0) continue; if(i+j == b){ ans[i] = 2; ans[j] = 2; done = 1; break; } } if(done) break; } } int sums[4] = {0}; for(int i= 1;i<=n;i++){ if(ans[i] == 0) ans[i] = 3; sums[ans[i]]+=i; } if(sums[1] == sums[2]-1 && sums[2] == sums[3]-1){ for(int i= 1;i<=n;i++){ cout<<ans[i]<<' '; } cout<<endl; } else { cout<<"IMPOSSIBLE"<<endl; } } 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 |
---|
3 3 3 1 2 |
Test 4
Group: 1, 2
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
1 3 2 2 1 3 |
user output |
---|
3 2 3 3 2 1 |
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 |
---|
3 3 1 3 2 3 2 1 |
Test 7
Group: 1, 2
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
1 2 3 1 2 3 3 2 1 |
user output |
---|
3 3 3 3 1 3 2 2 1 |
Test 8
Group: 1, 2
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
42 |
correct output |
---|
1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ... |
user output |
---|
IMPOSSIBLE |
Test 10
Group: 2
Verdict: WRONG ANSWER
input |
---|
95 |
correct output |
---|
1 3 1 3 2 1 2 3 3 2 1 1 2 3 3 ... |
user output |
---|
IMPOSSIBLE |
Test 11
Group: 2
Verdict: WRONG ANSWER
input |
---|
96 |
correct output |
---|
1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ... |
user output |
---|
IMPOSSIBLE |
Test 12
Group: 2
Verdict: ACCEPTED
input |
---|
97 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |
Test 13
Group: 2
Verdict: WRONG ANSWER
input |
---|
98 |
correct output |
---|
2 3 1 2 3 3 2 1 1 2 3 3 2 1 1 ... |
user output |
---|
IMPOSSIBLE |
Test 14
Group: 2
Verdict: WRONG ANSWER
input |
---|
99 |
correct output |
---|
1 2 3 1 2 3 3 2 1 1 2 3 3 2 1 ... |
user output |
---|
IMPOSSIBLE |
Test 15
Group: 2
Verdict: ACCEPTED
input |
---|
100 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |