| Task: | Kolmijako |
| Sender: | nikolai2001 |
| Submission time: | 2021-01-23 18:59:04 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 22 |
| #2 | ACCEPTED | 78 |
| 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 | ACCEPTED | 0.01 s | 2 | details |
| #10 | ACCEPTED | 0.01 s | 2 | details |
| #11 | ACCEPTED | 0.01 s | 2 | details |
| #12 | ACCEPTED | 0.01 s | 2 | details |
| #13 | ACCEPTED | 0.01 s | 2 | details |
| #14 | ACCEPTED | 0.01 s | 2 | details |
| #15 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:46:9: warning: unused variable 'a1' [-Wunused-variable]
int a1 = a2 - 1;
^~Code
#include<bits/stdc++.h>
using namespace std;
int r[101] = {0};
bool doTry(int n, int l){
if(n < 0 || l < 0) return false;
if(n == 0){
if(l == 0) return true;
else return false;
}
if(n == 1){
if(l != 1) return false;
if(r[n]) return false;
r[n] = 2;
//cout << n << endl;
return true;
}
if(!r[n]){
r[n] = 2;
if(doTry(min(n-1, l - n), l - n)){
//cout << n << endl;
return true;
}
r[n] = 0;
}
if(doTry(n-1, l)) return true;
return false;
}
int main(int argc, char *argv[]){
int n;
cin >> n;
int sum = (1+n)*n/2;
if(sum % 3){
cout << "IMPOSSIBLE" << endl;
return 0;
}
int a2 = sum / 3;
int a1 = a2 - 1;
int a3 = a2 + 1;
int t = a3;
int m = n;
while(t){
int s = min(m--, t);
//cout << s << endl;
r[s] = 3;
t -= s;
}
//cout << endl;
t = a2;
m++;
if(!doTry(m, a2)){
cout << "IMPOSSIBLE" << endl;
}
char ch[3] = " ";
for(int i = 1; i <= n; i++){
int f = r[i];
if(!f) f = 1;
f += '0';
ch[0] = f;
cout << ch;
}
cout << endl;
}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 2 2 1 3 |
Test 4
Group: 1, 2
Verdict: ACCEPTED
| input |
|---|
| 6 |
| correct output |
|---|
| 1 3 2 2 1 3 |
| user output |
|---|
| 1 3 2 2 1 3 |
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 |
|---|
| 2 1 1 2 3 1 2 3 |
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: ACCEPTED
| input |
|---|
| 42 |
| correct output |
|---|
| 1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ... |
| user output |
|---|
| 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 10
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 95 |
| correct output |
|---|
| 1 3 1 3 2 1 2 3 3 2 1 1 2 3 3 ... |
| user output |
|---|
| 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Truncated |
Test 11
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 96 |
| correct output |
|---|
| 1 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ... |
| user output |
|---|
| 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Truncated |
Test 12
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 97 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
Test 13
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 98 |
| correct output |
|---|
| 2 3 1 2 3 3 2 1 1 2 3 3 2 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 ... Truncated |
Test 14
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 99 |
| correct output |
|---|
| 1 2 3 1 2 3 3 2 1 1 2 3 3 2 1 ... |
| user output |
|---|
| 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Truncated |
Test 15
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 100 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
