Submission #75869

# Submission time Handle Problem Language Result Execution time Memory
75869 2018-09-11T11:49:25 Z kdh9949 Combo (IOI18_combo) C++17
0 / 100
75 ms 236 KB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

const static char b[5] = "ABXY";

static string r;
static char a[3];

string guess_sequence(int N) {
    int x = press(string("XY"));
    int y = press(string("BY"));
    r += b[2 * !!x + !!y];
    for(int i = 0, j = 0; i < 4; i++) if(i != 2 * x + y) a[j++] = b[i];
    for(int x; r.length() < N - 1; ){
        x = press(r + a[0] + a[0] + r + a[0] + a[1] + r + a[1] + a[0]);
        if(!x){ r += a[2]; continue; }
        if(x == r.length() + 1){
            x = press(r + a[1] + r + a[1] + a[1]);
            if(x == r.length()){ r += a[0]; r += a[2]; }
            if(x == r.length() + 1){ r += a[1]; r += a[2]; }
            if(x == r.length() + 2){ r += a[1]; r += a[1]; }
        }
        else{
            x = press(r + a[0] + r + a[0] + a[0]);
            if(x == r.length()){ r += a[1]; r += a[0]; }
            if(x == r.length() + 1){ r += a[0]; r += a[1]; }
            if(x == r.length() + 2){ r += a[0]; r += a[0]; }
        }
    }
    if(r.length() < N){
        int x = press(r + "X" + r + "Y");
        int y = press(r + "B" + r + "Y");
        r += b[2 * (x - r.length()) + (y - r.length())];
    }
    return r;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     for(int x; r.length() < N - 1; ){
      |                ~~~~~~~~~~~^~~~~~~
combo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(x == r.length() + 1){
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             if(x == r.length()){ r += a[0]; r += a[2]; }
      |                ~~^~~~~~~~~~~~~
combo.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if(x == r.length() + 1){ r += a[1]; r += a[2]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if(x == r.length() + 2){ r += a[1]; r += a[1]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if(x == r.length()){ r += a[1]; r += a[0]; }
      |                ~~^~~~~~~~~~~~~
combo.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if(x == r.length() + 1){ r += a[0]; r += a[1]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if(x == r.length() + 2){ r += a[0]; r += a[0]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:31:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if(r.length() < N){
      |        ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 2 ms 200 KB Output is correct
6 Correct 1 ms 236 KB Output is correct
7 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 2 ms 200 KB Output is correct
17 Runtime error 75 ms 200 KB Execution failed because the return code was nonzero
18 Halted 0 ms 0 KB -