Task: | Järjestys |
Sender: | yhyy |
Submission time: | 2016-10-15 23:32:19 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 19 |
#2 | ACCEPTED | 37 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.05 s | 2 | details |
#3 | ACCEPTED | 0.10 s | 3 | details |
Code
#include <iostream> using namespace std; int t[101010], V; void vaihda(int k){ if(k==2) { cout << k <<" "; ++V; } else { cout << k-1 << " " << k-2 << " " << k-1 << " " << k << " "; V+=4; } } void kaanna(int k){ if(k==1) return; cout << k << " "; ++V; } int main(){ int n, c=1, d=0; cin >> n; for(int i=1; i<=n; ++i){ cin >> t[i]; if(t[i]==i) ++d; } cout << 5*n << "\n"; while(d<n){ if(t[1]==c){ swap(t[1], t[c]); kaanna(c); while(t[c]==c) ++c; if(c>n) break; swap(t[1], t[c]); kaanna(c); } int a=t[1]; vaihda(a); swap(t[1], t[a]); ++d; } for(++V; V<=5*n; ++V) cout << "1 "; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
10 9 3 4 7 6 5 10 2 8 1 |
correct output |
---|
32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
user output |
---|
50 8 7 8 9 7 6 7 8 2 2 1 2 3 3 2 ... |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
5000 649 648 649 650 327 326 327 32... |
Test 3
Group: 3
Verdict: ACCEPTED
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
500000 94702 94701 94702 94703 71576 ... |