답안 #95739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95739 2019-02-02T08:39:22 Z SomeoneUnknown 콤보 (IOI18_combo) C++14
0 / 100
2 ms 200 KB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
    if(N == 1){
        if(press("AB") == 1){
            if(press("A") == 1){
                return "A";
            }else{
                return "B";
            }
        }else{
            if(press("X") == 1){
                return "X";
            }else{
                return "Y";
            }
        }
    }
    int r = press("ABXAXBA");
    string combo = "";
    if(r >= 2){
        string ord = "ABX";
        if(press("ABXA") == 1){
            ord = "AXB";
        }
        string p = "A" + ord[1];
        switch(press(p)){
            case 2: combo = p; break;
            case 1: combo += ord[1]; combo += ord[2]; break;
            case 0: combo += ord[2]; combo += ord[0]; break;
        }
    }else if(r == 1){
        if(press("BX") == 1){
            if(press("B") == 1){
                combo = "BY";
            }else{
                combo = "XY";
            }
        }else{
            combo = "AY";
        }
    }else if(r == 0){
        if(press("YBYX") == 2){
            if(press("YB") == 2){
                combo = "YB";
            }else{
                combo = "YX";
            }
        }else{
            combo = "YA";
        }
    }
    vector<char> nfirst;
    string x = "ABXY";
    for(int i = 0; i < 4; i++){
        if(combo[0] != x[i]){
            nfirst.push_back(x[i]);
        }
    }
    if(N == 2){
        return combo;
    }
    for(int i = 2; i < N-1; i++){
        string ask = combo + x[1];
        for(int i = 0; i < 3; i++){
            ask += combo + x[2];
            ask += x[i];
        }
        int l = combo.length();
        combo += x[press(ask)-l];
    }
    if(combo.length() == press(combo + x[0])){
        return combo + x[0];
    }
    if(combo.length() == press(combo + x[1])){
        return combo + x[1];
    }
    return combo + x[2];
  /*std::string p = "";
  /*for (int i = 0; i < 4 * N; ++i) {
    p += 'A';
  }
  int coins = press(p);
  std::string S = "";
  for (int i = 0; i < N; ++i) {
    S += 'A';
  }
  return S;//*/
}

Compilation message

combo.cpp:81:3: warning: "/*" within comment [-Wcomment]
   81 |   /*for (int i = 0; i < 4 * N; ++i) {
      |    
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:73:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |     if(combo.length() == press(combo + x[0])){
      |        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:76:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   76 |     if(combo.length() == press(combo + x[1])){
      |        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 200 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
6 Halted 0 ms 0 KB -