Task: | Split in Three |
Sender: | kenechi |
Submission time: | 2021-01-31 11:57:42 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 22 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 22 |
#2 | TIME LIMIT EXCEEDED | 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 | ACCEPTED | 0.04 s | 2 | details |
#10 | TIME LIMIT EXCEEDED | -- | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 2 | details |
#12 | ACCEPTED | 0.01 s | 2 | details |
#13 | TIME LIMIT EXCEEDED | -- | 2 | details |
#14 | TIME LIMIT EXCEEDED | -- | 2 | details |
#15 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'void check(std::vector<long long int>&)': input/code.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (; id < v.size(); id++) { ~~~^~~~~~~~~~ input/code.cpp:28:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (; id < v.size(); id++) { ~~~^~~~~~~~~~ input/code.cpp:39:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (; id < v.size(); id++) { ~~~^~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define maxn 200010 const int MOD = 1000000007; int need; void check(vector<int> &v) { int id = 0, sum = 0; bool fd1 = false; bool fd2 = false; bool fd3 = false; vector<int> now(v.size(), 1); for (; id < v.size(); id++) { sum += v[id]; if (sum == need - 1) { fd1 = 1; break; } } id++; sum = 0; for (; id < v.size(); id++) { sum += v[id]; now[v[id] - 1] = 2; if (sum == need) { fd2 = 1; break; } } id++; sum = 0; for (; id < v.size(); id++) { sum += v[id]; now[v[id] - 1] = 3; if (sum == need + 1) { fd3 = 1; break; } } if (fd1 and fd2 and fd3) { for (auto x: now)cout << x << " "; exit(0); } } void solve() { int n; cin >> n; vector<int> v(n); iota(v.begin(), v.end(), 1ll); // v = {1, 3, 7, 4, 8, 2, 5, 6}; if (n * (n + 1) % 6) { cout << "IMPOSSIBLE" << endl; return; } need = n * (n + 1) / 6; do { check(v); } while (next_permutation(v.begin(), v.end())); cout << "IMPOSSIBLE" << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) solve(); 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 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 |
---|
1 1 1 2 2 2 3 1 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: TIME LIMIT EXCEEDED
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: TIME LIMIT EXCEEDED
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: TIME LIMIT EXCEEDED
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: TIME LIMIT EXCEEDED
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 |