| Task: | Letter Game |
| Sender: | Wave of Technology |
| Submission time: | 2018-05-26 15:59:39 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.01 s | details |
| #4 | ACCEPTED | 0.01 s | details |
| #5 | ACCEPTED | 0.01 s | details |
| #6 | ACCEPTED | 0.01 s | details |
| #7 | ACCEPTED | 0.01 s | details |
| #8 | ACCEPTED | 0.01 s | details |
| #9 | ACCEPTED | 0.02 s | details |
| #10 | WRONG ANSWER | 0.01 s | details |
| #11 | WRONG ANSWER | 0.01 s | details |
| #12 | WRONG ANSWER | 0.01 s | details |
| #13 | WRONG ANSWER | 0.01 s | details |
| #14 | WRONG ANSWER | 0.01 s | details |
| #15 | WRONG ANSWER | 0.01 s | details |
| #16 | WRONG ANSWER | 0.01 s | details |
| #17 | WRONG ANSWER | 0.01 s | details |
| #18 | WRONG ANSWER | 0.01 s | details |
| #19 | WRONG ANSWER | 0.01 s | details |
Compiler report
input/code.cpp: In function 'll solve()':
input/code.cpp:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
input/code.cpp: In function 'int main()':
input/code.cpp:89:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res.size() != i) { continue; }
~~~~~~~~~~~^~~~
input/code.cpp:100:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res.size() != i) { continue; }
~~~~~~~~~~~^~~~Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
const ll INF = 1000000000000000LL;
ll n;
template<typename T>
void print_vector(vector<T> & v) {
for (auto x : v) {
cout << x << " ";
}
}
ll solve() {
ll n, m;
cin >> n >> m;
}
bool test(string s) {
bool bfound = false;
for (auto c : s) {
if (c=='B') { bfound = true; }
if (bfound && c == 'A') { return false;}
}
return true;
}
int main() {
cin.tie(NULL);
std::ios::sync_with_stdio(false);
ll n;
cin >> n;
string s;
cin >> s;
if (n==1) {
cout << "0\n";
return 0;
}
if (n==2) {
for (char c : s) {
if (c=='A') {
cout << "0\n";
return 0;
}
if (c=='B') {
cout << "-1\n";
return 0;
}
}
}
n = 2*n;
vector<string> res;
for (int i=0; i<1000; i++) {
int xpos = 0;
for (int j=0; j<n; j++) {
if (s[j] == '.') {
xpos = j;
break;
}
}
for (int j=0; j<xpos; j++) {
if (s[j] == 'B' && s[j+1] == 'B') {
swap(s[j], s[xpos]);
swap(s[j+1], s[xpos+1]);
res.push_back(s);
break;
}
}
if (res.size() != i) { continue; }
for (int j=xpos; j<n-1; j++) {
if (s[j] == 'A' && s[j+1] == 'A') {
swap(s[j], s[xpos]);
swap(s[j+1], s[xpos+1]);
res.push_back(s);
break;
}
}
if (res.size() != i) { continue; }
while(true) {
int j = rand() % (n-1);
// cout << j << " " << xpos << endl;
if (abs(j-xpos) >=2) {
swap(s[j], s[xpos]);
swap(s[j+1], s[xpos+1]);
res.push_back(s);
break;
}
}
if (test(res.back())) { break; }
}
if (!test(res.back())) { cout << -1 << endl; return 0; }
cout << res.size() << endl;
for (auto ss : res) {
cout << ss << endl;
}
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 .. |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 2 A..B |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 2 B..A |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 3 AA..BB |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 ..AABB |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 3 AB..AB |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 3 AB..BA |
| correct output |
|---|
| 2 ABBA.. A..ABB |
| user output |
|---|
| 9 ..ABBA BBA..A ..ABBA AB..BA ... |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 3 BA..AB |
| correct output |
|---|
| 2 ..BAAB AAB..B |
| user output |
|---|
| 5 ..BAAB AAB..B ..BAAB AAB..B ... |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 3 BA..BA |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 3 BB..AA |
| correct output |
|---|
| 2 ..BBAA AABB.. |
| user output |
|---|
| 4 ..BBAA AABB.. AA..BB ..AABB |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 100 BBABAABBBAAAAABBBBBBAAAABAAABA... |
| correct output |
|---|
| 140 ..ABAABBBAAAAABBBBBBAAAABAAABA... |
| user output |
|---|
| -1 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 100 AABBABBAAABABBBBBBBBAABABAAAAB... |
| correct output |
|---|
| 142 AA..ABBAAABABBBBBBBBAABABAAAAB... |
| user output |
|---|
| -1 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 100 AAAAABAABBBABAABAAABABBAAAABAA... |
| correct output |
|---|
| 134 AAAAA..ABBBABAABAAABABBAAAABAA... |
| user output |
|---|
| -1 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 100 BBBAAAABAABABAABAABBBABBABABAA... |
| correct output |
|---|
| 142 ..BAAAABAABABAABAABBBABBABABAA... |
| user output |
|---|
| -1 |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 100 BABBBAAAAABABAAABBBAABBABABBBB... |
| correct output |
|---|
| 138 ..BBBAAAAABABAAABBBAABBABABBBB... |
| user output |
|---|
| -1 |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 100 ABAAAAABBAAAAAAAAAABABAABBBBBB... |
| correct output |
|---|
| 126 A..AAAABBAAAAAAAAAABABAABBBBBB... |
| user output |
|---|
| -1 |
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 100 ABBBBBABBABABABBBABAABAAAABBAA... |
| correct output |
|---|
| 128 A..BBBABBABABABBBABAABAAAABBAA... |
| user output |
|---|
| -1 |
Test 17
Verdict: WRONG ANSWER
| input |
|---|
| 100 BAAABBABBAAAABABAAABABABBAAABA... |
| correct output |
|---|
| 139 ..AABBABBAAAABABAAABABABBAAABA... |
| user output |
|---|
| -1 |
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| 100 BBBBBABBAAABBAABBBBBABABABAABA... |
| correct output |
|---|
| 133 ..BBBABBAAABBAABBBBBABABABAABA... |
| user output |
|---|
| -1 |
Test 19
Verdict: WRONG ANSWER
| input |
|---|
| 100 BABBBBBBABBBABBBBBBAABABAAABAA... |
| correct output |
|---|
| 128 ..BBBBBBABBBABBBBBBAABABAAABAA... |
| user output |
|---|
| -1 |
