답안 #314565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314565 2020-10-20T10:14:07 Z Jarif_Rahman 콤보 (IOI18_combo) C++17
0 / 100
73 ms 348 KB
#include "combo.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
str guess_sequence(int n){
    str s = "";
    int r = 0;
    if(press("AB")){
        if(press("A") > r) s+="A";
        else s+="B";
    }
    else{
        if(press("X") > r) s+="X";
        else s+="Y";
    }
    r++;
    if(n == 1) return s;
    str ss = ""; for(char c: "ABXY") if(c != s[0]) ss+=str(1, c);
    if(press(s+str(1, ss[0]) + s+str(1, ss[1])) > r){
        if(press(s + str(1, ss[0])) > r) s+=str(1, ss[0]);
        else s+=str(1, ss[1]);
    }
    else s+=str(1, ss[2]);
    r++;
    while(s.size() < n){
        ss = ""; for(char c: "ABXY") if(c != s.front() && c != s.back()) ss+=c;
        int sz = n - s.size();
        str s1 = s+str(sz, ss[0]), s2 = s+str(sz, ss[1]);
        int x = press(s1);
        if(x > r) s = s1.substr(0, x);
        else{
            x = press(s2);
            s = s2.substr(0, x);
        }
        r = x;
    }
    return s;

}

Compilation message

combo.cpp: In function 'str guess_sequence(int)':
combo.cpp:29:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while(s.size() < n){
      |           ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 73 ms 220 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 1 ms 248 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 1 ms 200 KB Output is correct
17 Partially correct 30 ms 348 KB Output is partially correct
18 Runtime error 63 ms 288 KB Execution failed because the return code was nonzero
19 Halted 0 ms 0 KB -