제출 #1230710

#제출 시각아이디문제언어결과실행 시간메모리
1230710riddles콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<ll, ll> mp;
typedef pair<ll, ll> pll;
typedef queue<ll> qi;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector <vi> vvi;
typedef vector <pll> vpl;
typedef vector <string> vs;
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define F first
#define S second
#define pb push_back
#define all(x) begin(x), end(x)


void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if ((ll)(name.size())) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

ll go(){
    ll q=press("AB");
    if(q>=1){
        q=press("A");
        if(q==1) return 0;
        else return 1;
    }else{
        q=press("X");
        if(q==1) return 2;
        else return 3;
    }
}

string guess_sequence(ll n){
    string ans="";
    vector<char> idx={'A', 'B', 'X', 'Y'};
    ll a=go();
    ll q=n-2;
    ans+=idx[a];
    ll i=1;
    if(idx[a]=='A'){
        while(q--){
            string test="";
            test+=ans;
            test+='B';
            test+=ans;
            test+="XY";
            test+=ans;
            test+="XB";
            test+=ans;
            test+="XX";
            ll k=press(test);
            if(k==i) ans+='Y';
            else if(k==i+1) ans+='B';
            else ans+='X';
            i++;
        }
    }
        if(idx[a]=='B'){
        while(q--){
            string test="";
            test+=ans;
            test+='A';
            test+=ans;
            test+="XY";
            test+=ans;
            test+="XA";
            test+=ans;
            test+="XX";
            ll k=press(test);
            if(k==i) ans+='Y';
            else if(k==i+1) ans+='A';
            else ans+='X';
            i++;
        }
    }
        if(idx[a]=='X'){
        while(q--){
            string test="";
            test+=ans;
            test+='B';
            test+=ans;
            test+="AY";
            test+=ans;
            test+="AB";
            test+=ans;
            test+="AA";
            ll k=press(test);
            if(k==i) ans+='Y';
            else if(k==i+1) ans+='B';
            else ans+='A';
            i++;
        }
    }
    if(idx[a]=='Y'){
        while(q--){
            string test="";
            test+=ans;
            test+="B";
            test+=ans;
            test+="XA";
            test+=ans;
            test+="XB";
            test+=ans;
            test+="XX";
            ll k=press(test);
            if(k==i) ans+='A';
            else if(k==i+1) ans+='B';
            else ans+='X';
            i++;
        }
    }
    return ans;
}

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

combo.cpp: In function 'll go()':
combo.cpp:31:10: error: 'press' was not declared in this scope
   31 |     ll q=press("AB");
      |          ^~~~~
combo.cpp: In function 'std::string guess_sequence(ll)':
combo.cpp:61:18: error: 'press' was not declared in this scope
   61 |             ll k=press(test);
      |                  ^~~~~
combo.cpp:79:18: error: 'press' was not declared in this scope
   79 |             ll k=press(test);
      |                  ^~~~~
combo.cpp:97:18: error: 'press' was not declared in this scope
   97 |             ll k=press(test);
      |                  ^~~~~
combo.cpp:115:18: error: 'press' was not declared in this scope
  115 |             ll k=press(test);
      |                  ^~~~~
combo.cpp: In function 'void setIO(std::string)':
combo.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~