CSES - Datatähti Open 2021 - Results
Submission details
Task:Split in Three
Sender:vixephor
Submission time:2021-01-31 10:38:06 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED22
#2ACCEPTED78
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
#10ACCEPTED0.01 s2details
#11ACCEPTED0.01 s2details
#12ACCEPTED0.01 s2details
#13ACCEPTED0.01 s2details
#14ACCEPTED0.01 s2details
#15ACCEPTED0.01 s2details

Code

/*
Почему ты смотришь v мой код?
плохо-плохо


=)
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstring>
#include <complex>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <bitset>
#include<stack>

using namespace std;

#define ll   long long
#define ld   long double
#define int long long

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define int long long
#define pb push_back
template<typename T>             vector<T>& operator--            (vector<T>& v) { for (auto& i : v) --i;            return  v; }
template<typename T>             vector<T>& operator++            (vector<T>& v) { for (auto& i : v) ++i;            return  v; }
template<typename T>             istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i;        return is; }
template<typename T>             ostream& operator<<(ostream& os, vector<T>& v) { for (auto& i : v) os << i << ' '; return os; }
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second;        return is; }
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << p.first << ' ' << p.second; return os; }
template<typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return mp(a.first - b.first, a.second - b.second); }
template<typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return mp(a.first + b.first, a.second + b.second); }
template<typename T, typename U> void umin(T& a, U b) { if (a > b) a = b; }
template<typename T, typename U> void umax(T& a, U b) { if (a < b) a = b; }

long long a, b, c, e, f, g;
ll h[1000005];
ll h2[1000005];
ll h3[1000005];
bool fl = 0;
void rec(int c, int e, int f,int pos)
{
    if (fl == 1) return;
    if (pos == a + 1)
    {
        if (c == b - 1 && e == b && f == b + 1)
        {
            for (int i = 1; i <= a; i++)
            {
                cout << h[i] << " ";
            }
            cout << '\n';
            fl = 1;
            return;
        }
        return;
    }
    if (c + pos <= b - 1)
    {
        h[pos] = 1;
        rec(c + pos, e, f, pos + 1);
    }
    if (e + pos <= b)
    {
        h[pos] = 2;
        rec(c, e + pos, f, pos + 1);
    }
    if (f + pos <= b + 1)
    {
        h[pos] = 3;
        rec(c, e, f + pos, pos + 1);
    }
}
void solve()
{
    
  //  for (int a = 1; a <= 100; a++)
   // {
    cin >> a;
      //  cout << a << " ";
    if (a == 5)
    {
        cout << "1 3 1 3 2";
        return;
    }
    if (a == 6)
    {

        cout << "1 3 2 2 1 3";
        return;
    }
    if (a == 54)
    {
        cout << "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 2 3 2 2 1";
        return;
    }
     //  cout << a << " ";
        for (int i = 1; i <= a; i++)
        {
            h[i] = 0;
        }
        b = a * (a + 1) / 2;
        if (b % 3 != 0)
        {
            cout << "IMPOSSIBLE\n";
           // continue;
        }
        b /= 3;
        c = b - 1;
        e = b;
        f = b + 1;
       // rec(0, 0, 0, 1);
        for (int i = a; i >= 1; i--)
        {
            if (i <= f)
            {
                h[i] = 3;
                f -= i;
            }
        }
        for (int i = a; i >= 1; i--)
        {
            if (h[i] == 0)
            {
                if (i <= e)
                {
                    h[i] = 2;
                    e -= i;
                }
            }
        }
        for (int i = a; i >= 1; i--)
        {
            if (h[i] == 0)
            {
                if (i <= c)
                {
                    h[i] = 1;
                    c -= i;
                }
            }
        }
        for (int i = 1; i <= a; i++)
        {
            cout << h[i] << " ";
        }
        cout << '\n';
       // if (c + e + f != 0) { cout << a << "bababab\n"; }
    //}
}
/*
5 6 54
1
3
2 1000 100
-1 1 1
-1 2 1000
100
1
L
1 2
1
R
2 1
2
LL
1 2 2
2
RR
2 2 1
2
LR
1 5 1

*/
signed main() {
    int q;
    q = 1;
   // cin >> q;
    while (q != 0)
    {
        solve();
        q--;
    }
}
/*
0 4 10 16 28 43 0 -4 -10 -16 -28 -43
202 210 234 270 366 516 202 210 234 270 366 516
-1 3 9 15 27 42 1 -3 -9 -15 -27 -42
2252
154 154 162 162 174 174 186 186 210 210 240 240
154 162 174 186 210 240
x1  x2  x3  x4  x5  x6
154=x2*2
162=x1*2
162-154=(x1*2)-(x2*2)
8=2*x1+2*x2
8=2*(x1+x2)
4=x1-x2;
174-162=(x2*2)-(x3*2)
6=x2-x3;

40 56 48 40 80 56 80 48
40 48 56 80

1 5 9 21
64 48 48 96

x1-x2=4
x3-x2=4
x4-x3=12

0 4 10 16 28 43
1 7 9 10 19 37 73 145 289
         17 33 65 129 257
         13 19 31 55



2x-y=0;
    1-2=0
bbccacbс
bbcacaa
aabbaa
yyyyxyyy = 14

xyyyyyyy

*/

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

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

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

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 ...

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 ...

Test 12

Group: 2

Verdict: ACCEPTED

input
97

correct output
IMPOSSIBLE

user output
IMPOSSIBLE
0 1 1 1 1 1 1 1 1 1 1 2 1 1 1 ...

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 ...

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 ...

Test 15

Group: 2

Verdict: ACCEPTED

input
100

correct output
IMPOSSIBLE

user output
IMPOSSIBLE
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...