답안 #349118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349118 2021-01-16T17:36:50 Z spike1236 콤보 (IOI18_combo) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;


bool check(char x) {
    string s = "";
    s += x;
    int cnt = press(s);
    if(cnt > 1 || !cnt) return 0;
    return 1;
}
string guess_sequence(int n) {
    string cur = "";
    set <char> st;
    st.insert('A');
    st.insert('B');
    st.insert('X');
    st.insert('Y');
    if(check('A')) cur = "A", st.erase('A');
    else if(check('B')) cur = "B", st.erase('B');
    else if(check('X')) cur = "X", st.erase('X');
    else cur = "Y", st.erase('Y');
    auto it = st.begin();
    vector <char> a;
    a.pb(*it);
    ++it;
    a.pb(*it);
    ++it;
    a.pb(*it);
    for(int i = 1; i < n; ++i) {
        veci was(3);
        for(int j = 0; j < 2; ++j) {
            int key = rand() % 3;
            while(was[key]) key = rand() % 3;
            if(press(cur + a[key]) == i + 1) {
                cur += a[key];
                break;
            }
            was[key] = 1;
        }
    }
    return cur;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:7: error: 'class std::vector<char>' has no member named 'pb'
   26 |     a.pb(*it);
      |       ^~
combo.cpp:28:7: error: 'class std::vector<char>' has no member named 'pb'
   28 |     a.pb(*it);
      |       ^~
combo.cpp:30:7: error: 'class std::vector<char>' has no member named 'pb'
   30 |     a.pb(*it);
      |       ^~
combo.cpp:32:9: error: 'veci' was not declared in this scope
   32 |         veci was(3);
      |         ^~~~
combo.cpp:35:19: error: 'was' was not declared in this scope
   35 |             while(was[key]) key = rand() % 3;
      |                   ^~~
combo.cpp:40:13: error: 'was' was not declared in this scope
   40 |             was[key] = 1;
      |             ^~~