Task: | Merkkijono |
Sender: | Yytsi |
Submission time: | 2019-01-16 12:42:44 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.03 s | details |
#2 | WRONG ANSWER | 0.03 s | details |
#3 | WRONG ANSWER | 0.02 s | details |
#4 | WRONG ANSWER | 0.03 s | details |
#5 | WRONG ANSWER | 0.02 s | details |
Code
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i=a; i<(b); i++) #define IO ios_base::sync_with_stdio(0); cin.tie(0) #define ff first #define ss second #define pb push_back #define INF 2147483647 #define LINF (1LL<<61LL) typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; string s; int chars_between(int a, int b) { return abs(b-a)-1; } int Z = 26; vector<int> mv; void sw(int b, int a) { // b is actually the left point! s[b] > s[a] int pad = chars_between(a,b); int orig_b = b; // xxxBxxxxAxxx // pad = 4 // Move to state => // AxxxxxxBxxxx int shift1 = (Z-1) - a + 1; FOR(i,0,shift1) mv.pb(1); // A has to retain its place while shifting B next to it! while (b != (Z-1)) { mv.pb(1); mv.pb(2); b++; } // AxxxxxxxxxxB mv.pb(1); // BAxxxxxxxxxx mv.pb(2); // ABxxxxxxxxxx // Add the padding for // AxxxxBxxxxxx FOR(i,0,pad) mv.pb(1), mv.pb(2); // Shift A to the right place for xxxAxxxxBxxx FOR(i,0,orig_b) mv.pb(1); } int main() { IO; cin>>s; while (true) { bool swapped = false; FOR(b,0,Z) { FOR(a,b+1,Z) { if (s[b] > s[a]) { sw(b,a); swap(s[b], s[a]); swapped = true; } } } if (!swapped) break; } cout<<mv.size()<<"\n"; for (int v : mv) { if (v == 1) cout<<"MOVE\n"; else cout<<"SWAP\n"; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: WRONG ANSWER
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
22425 MOVE MOVE MOVE MOVE ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
10545 MOVE MOVE MOVE MOVE ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
8706 MOVE MOVE MOVE MOVE ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
7890 MOVE MOVE MOVE MOVE ... |