Task: | Merkkijono |
Sender: | Yytsi |
Submission time: | 2019-01-16 12:36:12 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.02 s | details |
#2 | WRONG ANSWER | 0.02 s | details |
#3 | WRONG ANSWER | 0.02 s | details |
#4 | WRONG ANSWER | 0.01 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; } 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 = 25 - a + 1; FOR(i,0,shift1) cout<<"MOVE\n"; // A has to retain its place while shifting B next to it! while (b != 25) { cout<<"MOVE\n"; cout<<"SWAP\n"; b++; } // AxxxxxxxxxxB cout<<"MOVE\n"; // BAxxxxxxxxxx cout<<"SWAP\n"; // ABxxxxxxxxxx // Add the padding for // AxxxxBxxxxxx FOR(i,0,pad) cout<<"MOVE\nSWAP\n"; // Shift A to the right place for xxxAxxxxBxxx FOR(i,0,orig_b) cout<<"MOVE\n"; } int main() { IO; cin>>s; while (true) { bool swapped = false; FOR(b,0,25) { FOR(a,b+1,25) { if (s[b] > s[a]) { sw(b,a); swap(s[b], s[a]); swapped = true; } } } if (!swapped) break; } }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 2
Verdict: WRONG ANSWER
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
MOVE MOVE MOVE MOVE MOVE ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
MOVE MOVE MOVE MOVE MOVE ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
MOVE MOVE MOVE MOVE MOVE ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
MOVE MOVE MOVE MOVE MOVE ... |