Submission #1309137

#TimeUsernameProblemLanguageResultExecution timeMemory
1309137coderg콤보 (IOI18_combo)C++20
100 / 100
8 ms480 KiB
#include "combo.h"
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
void setIO(string name = ""){if(name.size()){ freopen((name + ".in").c_str(), "r", stdin);freopen((name + ".out").c_str(), "w", stdout);}}
#define F(i,l,r) for(int i=(l);i<(r);++i)
#define FR(i,l,r) for(int i=(l);i>=(r);--i)
typedef long long ll;

string full="ABXY";

string guess_sequence(int N) {
  string ans="",s="";
  ans+=press("AB")?press("A")?"A":"B":press("X")?"X":"Y";
  for(char c:full){
    if(c!=ans[0])s+=c;
  }
  F(i,1,N-1){
    int send=press(ans+s[0]+s[0]+ans+s[0]+s[1]+ans+s[0]+s[2]+ans+s[1]);
    if(send==i)ans+=s[2];
    else if(send==i+1)ans+=s[1];
    else ans+=s[0];
  }
  if(N>1){
    if(press(ans+s[0])==N)ans+=s[0];
    else if(press(ans+s[1])==N)ans+=s[1];
    else ans+=s[2];
  }
  return ans;
}

Compilation message (stderr)

combo.cpp: In function 'void setIO(std::string)':
combo.cpp:11:54: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void setIO(string name = ""){if(name.size()){ freopen((name + ".in").c_str(), "r", stdin);freopen((name + ".out").c_str(), "w", stdout);}}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:11:98: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void setIO(string name = ""){if(name.size()){ freopen((name + ".in").c_str(), "r", stdin);freopen((name + ".out").c_str(), "w", stdout);}}
      |                                                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...