Submission #1230721

#TimeUsernameProblemLanguageResultExecution timeMemory
1230721riddlesCombo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h> #include "combo.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(int 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; }

Compilation message (stderr)

combo.cpp: In function 'void setIO(std::string)':
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 + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...