CSES - Datatähti Open 2021 - Results
Submission details
Task:Split in Three
Sender:dxz05
Submission time:2021-01-30 10:43:38 +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
#9ACCEPTED0.01 s2details
#100.01 s2details
#11ACCEPTED0.01 s2details
#12ACCEPTED0.01 s2details
#13ACCEPTED0.01 s2details
#14ACCEPTED0.01 s2details
#15ACCEPTED0.01 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:116:20: warning: statement has no effect [-Wunused-value]
         debug(test);
                    ^

Code

//#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << "[" << H << "]";
    debug_out(T...);
}

#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SZ(s) ((int)s.size())

clock_t startTime;

double getCurrentTime() {
    return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}

typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.00001;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e6 + 3e1;
const int M = 1111;

vector<int> A, B, C;

int ans[N];
void out(){
    int n = A.size() + B.size() + C.size();
    for (int i : A) ans[i] = 1;
    for (int i : B) ans[i] = 2;
    for (int i : C) ans[i] = 3;
    for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
    exit(0);
}

void solve(int TC) {
    int n;
    cin >> n;

    if (n * (n + 1) % 6 != 0 || n == 2){
        cout << "IMPOSSIBLE";
        return;
    }

    if (n % 6 == 0){
        A = {1, 5}, B = {3, 4}, C = {2, 6};
        for (int i = 7; i <= n; i++){
            if (i % 6 == 1 || i % 6 == 0) A.push_back(i);
            if (i % 6 == 2 || i % 6 == 5) B.push_back(i);
            if (i % 6 == 3 || i % 6 == 4) C.push_back(i);
        }
        out();
    }

    if (n % 6 == 2){
        A = {1, 3, 7}, B = {4, 8}, C = {2, 5, 6};
        for (int i = 9; i <= n; i++){
            if (i % 6 == 3 || i % 6 == 2) A.push_back(i);
            if (i % 6 == 4 || i % 6 == 1) B.push_back(i);
            if (i % 6 == 5 || i % 6 == 0) C.push_back(i);
        }
        out();
    }

    if (n % 6 == 3){
        A = {1}, B = {2}, C = {3};
        for (int i = 4; i <= n; i++){
            if (i % 6 == 4 || i % 6 == 3) A.push_back(i);
            if (i % 6 == 5 || i % 6 == 2) B.push_back(i);
            if (i % 6 == 0 || i % 6 == 1) C.push_back(i);
        }
        out();
    }

    if (n % 6 == 5){
        A = {1, 3}, B = {5}, C = {2, 4};
        for (int i = 6; i <= n; i++){
            if (i % 6 == 0 || i % 6 == 5) A.push_back(i);
            if (i % 6 == 1 || i % 6 == 3) B.push_back(i);
            if (i % 6 == 2 || i % 6 == 3) C.push_back(i);
        }
        out();
    }

}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false);

    bool llololcal = false;
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    llololcal = true;
#endif

    int TC = 1;
    //cin >> TC;

    for (int test = 1; test <= TC; test++) {
        debug(test);
        solve(test);
    }

    if (llololcal) cerr << endl << "Time: " << getCurrentTime() * 1000 << " ms" << 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
1 3 1 3 2 

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
1 3 1 2 3 3 1 2 

Test 7

Group: 1, 2

Verdict: ACCEPTED

input
9

correct output
1 2 3 1 2 3 3 2 1 

user output
1 2 3 1 2 3 3 2 1 

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 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ...

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
1 3 1 3 2 1 2 3 3 0 1 1 2 3 3 ...
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 3 2 2 1 3 1 2 3 3 2 1 1 2 3 ...
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 3 1 2 3 3 1 2 1 2 3 3 2 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 2 3 1 2 3 3 2 1 1 2 3 3 2 1 ...
Truncated

Test 15

Group: 2

Verdict: ACCEPTED

input
100

correct output
IMPOSSIBLE

user output
IMPOSSIBLE