제출 #1338180

#제출 시각아이디문제언어결과실행 시간메모리
1338180Johan콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int n) {
  string s = "";
  if(n == 1){
    for(int i = 0; i < v.size() - 1; i++){
    	if(press(s + v[i])){
        s += v[i];
        break;
    	}
    }
    if(!s.size())s += v.back();
  }
  s = "AB";
  if(press(s) == 0){
    if(press("X") == 0)
      s = "Y";
    else
      s = "X";
  }
  else {
    if(press("A") == 0)
      s = "B";
    else
      s = "A";
  }
	vector < char > vv;
	for(char c : v){
		if(c != s[0])
			vv.push_back(c);
	}
	if(n == 1){
		return s;
	}
	v = vv;
	while(s.size() <= n - 2){
		string cur = "";
		cur += (s + v[0]);
		cur += (s + v[1] + v[0]);
		cur += (s + v[1] + v[1]);
		cur += (s + v[1] + v[2]);
		int g = press(cur);
		if(g == s.size()){
			s += v[2];
		}
		else if(g == s.size() + 1){
			s += v[0];
		}
		else {
			s += v[1];
		}
	}
	string cur = "";
	cur += (s + v[0]);
	cur += (s + v[1]);
	if(press(cur) == s.size()){
		cur.clear();
		cur += (s + v[2]);
	}
	else {
		cur.clear();
		if(press(s + v[0]) == s.size())
			cur += (s + v[1]);
		else
			cur += (s + v[0]);
	}
//	cout << cur << endl;
	return cur;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:24: error: 'v' was not declared in this scope
    8 |     for(int i = 0; i < v.size() - 1; i++){
      |                        ^
combo.cpp:14:23: error: 'v' was not declared in this scope
   14 |     if(!s.size())s += v.back();
      |                       ^
combo.cpp:30:22: error: 'v' was not declared in this scope
   30 |         for(char c : v){
      |                      ^
combo.cpp:37:9: error: 'v' was not declared in this scope; did you mean 'vv'?
   37 |         v = vv;
      |         ^
      |         vv