| Task: | Merkkijono |
| Sender: | Olli |
| Submission time: | 2018-01-18 13:02:28 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | TIME LIMIT EXCEEDED | -- | details |
| #4 | TIME LIMIT EXCEEDED | -- | details |
| #5 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'bool inOrder(std::string)':
input/code.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < s.length() - 1; ++i) {
^
input/code.cpp: In function 'int main()':
input/code.cpp:44:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < oper.size(); ++i) {
^Code
#include <iostream>
#include <vector>
using namespace std;
vector<string> oper;
bool inOrder(string s) {
for(int i = 0; i < s.length() - 1; ++i) {
if((int) s[i+1] < (int) s[i]) {
return false;
}
}
return true;
}
int main() {
string s;
cin >> s;
int n = 26;
while(!inOrder(s)) {
//cout << s << "\n";
if((int) s[0] > (int) s[1]) {
oper.push_back("SWAP");
char a = s[0];
s[0] = s[1];
s[1] = a;
} else {
string newString = "";
newString += s[n-1];
for(int i = 0; i < n-1; ++i) {
newString += s[i];
}
s = newString;
oper.push_back("MOVE");
}
}
cout << oper.size() << "\n";
for(int i = 0; i < oper.size(); ++i) {
cout << oper[i] << "\n";
}
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| ABCDEFGHIJKLMNOPQRSTUVWXYZ |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| ZYXWVUTSRQPONMLKJIHGFEDCBA |
| correct output |
|---|
| 923 MOVE MOVE SWAP MOVE ... |
| user output |
|---|
| (empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| RPJMFWBHYQOTXUAENLDGZISCVK |
| correct output |
|---|
| 611 SWAP MOVE MOVE SWAP ... |
| user output |
|---|
| (empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| GWJSPBHANMXYFLKIDORVUCEZQT |
| correct output |
|---|
| 659 MOVE SWAP MOVE SWAP ... |
| user output |
|---|
| (empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| BJYNFLKEIUCZMQHRAXOGWPSDTV |
| correct output |
|---|
| 624 MOVE SWAP MOVE SWAP ... |
| user output |
|---|
| (empty) |
