제출 #919585

#제출 시각아이디문제언어결과실행 시간메모리
919585Khanhcsp2콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
//#include "combo.h"
#include <bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
//#define int long long
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
//const int N=1e5+11;
//namespace {
//
//constexpr int MAX_N = 2000;
//constexpr int MAX_NUM_MOVES = 8000;
//
//int N;
//std::string S;
//
//int num_moves;
//
//void wrong_answer(const char *MSG) {
//  printf("Wrong Answer: %s\n", MSG);
//  exit(0);
//}
//
//}  // namespace
//
//int press(std::string p) {
//  if (++num_moves > MAX_NUM_MOVES) {
//    wrong_answer("too many moves");
//  }
//  int len = p.length();
//  if (len > 4 * N) {
//    wrong_answer("invalid press");
//  }
//  for (int i = 0; i < len; ++i) {
//    if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
//      wrong_answer("invalid press");
//    }
//  }
//  int coins = 0;
//  for (int i = 0, j = 0; i < len; ++i) {
//    if (j < N && S[j] == p[i]) {
//      ++j;
//    } else if (S[0] == p[i]) {
//      j = 1;
//    } else {
//      j = 0;
//    }
//    coins = std::max(coins, j);
//  }
//  return coins;
//}
string guess_sequence(int n)
{
    string s="ABXY", ans="";
    int ch, pos;
    ch=press("AB");
    if(ch)
    {
        int v=press("A");
        if(v) pos=0;
        else pos=1;
    }
    else
    {
        int v=press("X");
        if(v) pos=2;
        else pos=3;
    }
    ans+=s[pos];
    if(n==1) return ans;
    swap(s[pos], s[3]);
    for(int i=1;i<n-1;i++)
    {
        string tmp=ans+s[0]+s[0]+ans+s[0]+s[1]+ans+s[0]+s[2]+ans+s[1];
//        cout << tmp << el;
        int l=press(tmp);
//        cout << l << el;
        if(l==i+2) ans+=s[0];
        else if(l==i+1) ans+=s[1];
        else ans+=s[2];
    }
//    cout << ans << el;
    if(press(ans+s[0])==n) return ans+s[0];
    else if(press(ans+s[1])==n) return ans+s[1];
    else return ans+s[2];
}
//int main() {
//  cin >> S;
//  N = S.length();
//
//  num_moves = 0;
//  std::string answer = guess_sequence(N);
//  if (answer != S) {
//    wrong_answer("wrong guess");
//    exit(0);
//  }
//  printf("Accepted: %d\n", num_moves);
//  return 0;
//}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:8: error: 'press' was not declared in this scope
   60 |     ch=press("AB");
      |        ^~~~~
combo.cpp:58:14: warning: control reaches end of non-void function [-Wreturn-type]
   58 |     string s="ABXY", ans="";
      |              ^~~~~~