제출 #1230716

#제출 시각아이디문제언어결과실행 시간메모리
1230716riddles콤보 (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);
    }
}

int press(string p){
    
}

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 'int press(std::string)':
combo.cpp:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
   32 | }
      | ^
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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cccKMvBo.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccXPF0z0.o:combo.cpp:(.text.unlikely+0x0): first defined here
/usr/bin/ld: /tmp/cccKMvBo.o: in function `main':
grader.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
collect2: error: ld returned 1 exit status