Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 15:59:39
Task:Letter Game
Sender:Wave of Technology
Submission time:2018-05-26 15:59:39
Language:C++
Status:READY
Result:WRONG ANSWER

Test results

testverdicttime (s)
#1ACCEPTED0.01 / 1.00details
#2ACCEPTED0.01 / 1.00details
#3ACCEPTED0.01 / 1.00details
#4ACCEPTED0.01 / 1.00details
#5ACCEPTED0.01 / 1.00details
#6ACCEPTED0.01 / 1.00details
#7ACCEPTED0.01 / 1.00details
#8ACCEPTED0.01 / 1.00details
#9ACCEPTED0.02 / 1.00details
#10WRONG ANSWER0.01 / 1.00details
#11WRONG ANSWER0.01 / 1.00details
#12WRONG ANSWER0.01 / 1.00details
#13WRONG ANSWER0.01 / 1.00details
#14WRONG ANSWER0.01 / 1.00details
#15WRONG ANSWER0.01 / 1.00details
#16WRONG ANSWER0.01 / 1.00details
#17WRONG ANSWER0.01 / 1.00details
#18WRONG ANSWER0.01 / 1.00details
#19WRONG ANSWER0.01 / 1.00details

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
..
view   save

correct output
0
view   save

user output
0
view   save

Test 2

Verdict: ACCEPTED

input
2
A..B
view   save

correct output
0
view   save

user output
0
view   save

Test 3

Verdict: ACCEPTED

input
2
B..A
view   save

correct output
-1
view   save

user output
-1
view   save

Test 4

Verdict: ACCEPTED

input
3
AA..BB
view   save

correct output
0
view   save

user output
1
..AABB
view   save

Test 5

Verdict: ACCEPTED

input
3
AB..AB
view   save

correct output
-1
view   save

user output
-1
view   save

Test 6

Verdict: ACCEPTED

input
3
AB..BA
view   save

correct output
2
ABBA..
A..ABB
view   save

user output
9
..ABBA
BBA..A
..ABBA
AB..BA
ABBA..
A..ABB
ABBA..
A..ABB
AAB..B
view   save

Test 7

Verdict: ACCEPTED

input
3
BA..AB
view   save

correct output
2
..BAAB
AAB..B
view   save

user output
5
..BAAB
AAB..B
..BAAB
AAB..B
A..ABB
view   save

Test 8

Verdict: ACCEPTED

input
3
BA..BA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 9

Verdict: ACCEPTED

input
3
BB..AA
view   save

correct output
2
..BBAA
AABB..
view   save

user output
4
..BBAA
AABB..
AA..BB
..AABB
view   save

Test 10

Verdict: WRONG ANSWER

input
100
BBABAABBBAAAAABBBBBBAAAABAAABA...
view   save

correct output
140
..ABAABBBAAAAABBBBBBAAAABAAABA...
AB..AABBBAAAAABBBBBBAAAABAAABA...
ABAA..BBBAAAAABBBBBBAAAABAAABA...
A..ABABBBAAAAABBBBBBAAAABAAABA...
AAB..ABBBAAAAABBBBBBAAAABAAABA...
view   save

user output
-1
view   save

Test 11

Verdict: WRONG ANSWER

input
100
AABBABBAAABABBBBBBBBAABABAAAAB...
view   save

correct output
142
AA..ABBAAABABBBBBBBBAABABAAAAB...
AAAB..BAAABABBBBBBBBAABABAAAAB...
AAABBA..AABABBBBBBBBAABABAAAAB...
AAA..ABBAABABBBBBBBBAABABAAAAB...
AAAAB..BAABABBBBBBBBAABABAAAAB...
view   save

user output
-1
view   save

Test 12

Verdict: WRONG ANSWER

input
100
AAAAABAABBBABAABAAABABBAAAABAA...
view   save

correct output
134
AAAAA..ABBBABAABAAABABBAAAABAA...
AAAAAAB..BBABAABAAABABBAAAABAA...
AAAAAABBB..ABAABAAABABBAAAABAA...
AAAAAA..BBBABAABAAABABBAAAABAA...
AAAAAAABBBB..AABAAABABBAAAABAA...
view   save

user output
-1
view   save

Test 13

Verdict: WRONG ANSWER

input
100
BBBAAAABAABABAABAABBBABBABABAA...
view   save

correct output
142
..BAAAABAABABAABAABBBABBABABAA...
AAB..AABAABABAABAABBBABBABABAA...
AABAA..BAABABAABAABBBABBABABAA...
AA..ABABAABABAABAABBBABBABABAA...
AAAB..ABAABABAABAABBBABBABABAA...
view   save

user output
-1
view   save

Test 14

Verdict: WRONG ANSWER

input
100
BABBBAAAAABABAAABBBAABBABABBBB...
view   save

correct output
138
..BBBAAAAABABAAABBBAABBABABBBB...
AABBB..AAABABAAABBBAABBABABBBB...
AA..BBBAAABABAAABBBAABBABABBBB...
AAAABBB..ABABAAABBBAABBABABBBB...
AAAA..BBBABABAAABBBAABBABABBBB...
view   save

user output
-1
view   save

Test 15

Verdict: WRONG ANSWER

input
100
ABAAAAABBAAAAAAAAAABABAABBBBBB...
view   save

correct output
126
A..AAAABBAAAAAAAAAABABAABBBBBB...
AAA..AABBAAAAAAAAAABABAABBBBBB...
AAAAA..BBAAAAAAAAAABABAABBBBBB...
AAAAAAABB..AAAAAAAABABAABBBBBB...
AAAAAAA..BBAAAAAAAABABAABBBBBB...
view   save

user output
-1
view   save

Test 16

Verdict: WRONG ANSWER

input
100
ABBBBBABBABABABBBABAABAAAABBAA...
view   save

correct output
128
A..BBBABBABABABBBABAABAAAABBAA...
AABBBB..BABABABBBABAABAAAABBAA...
AA..BBBBBABABABBBABAABAAAABBAA...
AAABBBBBB..ABABBBABAABAAAABBAA...
AAA..BBBBBBABABBBABAABAAAABBAA...
view   save

user output
-1
view   save

Test 17

Verdict: WRONG ANSWER

input
100
BAAABBABBAAAABABAAABABABBAAABA...
view   save

correct output
139
..AABBABBAAAABABAAABABABBAAABA...
AA..BBABBAAAABABAAABABABBAAABA...
AAABBB..BAAAABABAAABABABBAAABA...
AAA..BBBBAAAABABAAABABABBAAABA...
AAAAABBBB..AABABAAABABABBAAABA...
view   save

user output
-1
view   save

Test 18

Verdict: WRONG ANSWER

input
100
BBBBBABBAAABBAABBBBBABABABAABA...
view   save

correct output
133
..BBBABBAAABBAABBBBBABABABAABA...
ABBBB..BAAABBAABBBBBABABABAABA...
A..BBBBBAAABBAABBBBBABABABAABA...
AAABBBBB..ABBAABBBBBABABABAABA...
AAA..BBBBBABBAABBBBBABABABAABA...
view   save

user output
-1
view   save

Test 19

Verdict: WRONG ANSWER

input
100
BABBBBBBABBBABBBBBBAABABAAABAA...
view   save

correct output
128
..BBBBBBABBBABBBBBBAABABAAABAA...
ABBBBBBB..BBABBBBBBAABABAAABAA...
A..BBBBBBBBBABBBBBBAABABAAABAA...
AABBBBBBBBBB..BBBBBAABABAAABAA...
AA..BBBBBBBBBBBBBBBAABABAAABAA...
view   save

user output
-1
view   save