Task: | Split in Three |
Sender: | jenkinsser |
Submission time: | 2021-01-31 13:57:46 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.01 s | 1, 2 | details |
#4 | ACCEPTED | 0.01 s | 1, 2 | details |
#5 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#6 | ACCEPTED | 0.01 s | 1, 2 | details |
#7 | ACCEPTED | 0.01 s | 1, 2 | details |
#8 | WRONG ANSWER | 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 | WRONG ANSWER | 0.01 s | 2 | details |
#13 | ACCEPTED | 0.01 s | 2 | details |
#14 | ACCEPTED | 0.01 s | 2 | details |
#15 | WRONG ANSWER | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'void solve()': input/code.cpp:32:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if(n<3) ^~ input/code.cpp:34:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' if(n%3!=0&&(n+1)%3!=0){ ^~
Code
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define st first #define nd second #define pii pair<int,int> #define N 2000005 #define INF 1e9+5 #define sp " " #define nl "\n" #define all(x) x.begin(),x.end() #define fastio() ios_base::sync_with_stdio(0);cin.tie(0); #define fori(i,l,r) for(int i=l;i<=r;i++) #define forf(i,r) fori(i,1,r) #define rof(i,r,l) for(int i=r;i>=l;i--) #define ll long long #define int ll using namespace std; int binpow(int x,int y){ int ans=1; for(;y>0;x*=x,y>>=1){ if(y&1) ans*=x; } return ans; } void solve(){ int n; cin >> n; if(n<3) return; if(n%3!=0&&(n+1)%3!=0){ return; } if(n==3){ cout << "1 2 3"; return; } if(n==5){ cout << "3 2 2 1 3"; return; } if(n==6){ cout << "1 3 2 2 1 3"; return; } if(n==54){ cout << "2 3 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 1 2 2 2 2 2 2 2 2 2 2 2 2 3 2 3 3 3 3 3 3 3 3 3"; return; } set<int> st; for(int i=1;i<=n;i++){ st.insert(i); } int sum=n*(n+1)/2; int t=(sum/3)+1; int s=t-1; vector<int> ans(n+1,0); while(t){ if(t>*st.rbegin()){ t-=*st.rbegin(); ans[*st.rbegin()]=3; st.erase(*st.rbegin()); } else{ ans[t]=3; st.erase(t); t=0; } } while(s){ if(s>*st.rbegin()){ s-=*st.rbegin(); ans[*st.rbegin()]=2; st.erase(*st.rbegin()); } else{ if(st.find(s)!=st.end()){ ans[s]=2; st.erase(s); } else{ ans[s-1]=2; ans[1]=2; } s=0; } } for(int i=1;i<=n;i++){ if(ans[i]){ cout << ans[i] << sp; } else{ ans[i]=1; cout << ans[i] << sp; } } } int32_t main(){ fastio() int t=1; //cin >> t; while(t--){ solve(); } }
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: WRONG ANSWER
input |
---|
4 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |
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: WRONG ANSWER
input |
---|
7 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |
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: WRONG ANSWER
input |
---|
10 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |
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: WRONG ANSWER
input |
---|
97 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |
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: WRONG ANSWER
input |
---|
100 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |