제출 #493080

#제출 시각아이디문제언어결과실행 시간메모리
493080DDDNNN콤보 (IOI18_combo)C++14
100 / 100
38 ms644 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; #define forinc(i,a,b) for(int i=a;i<=b;i++) #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r) { return l+rng()%(r-l+1); } string d[]={"A","B","X","Y"}; bool dd[5]; string s=""; //int press(string s){}; string guess_sequence(int n) { int fi=4; int cnt=0; int num=0; int r=press("AB"); //cout<<"AB"; //int r;cin>>r; if(r>0) { r=press("A"); //cout<<"A";cin>>r; if(r>0) { s+="A";fi=0; } else s+="B",fi=1; } else { r=press("X"); //cout<<"X";cin>>r; if(r>0) s+="X",fi=2; else s+="Y",fi=3; } vector<string> c; forinc(i,0,3) { if(i==fi) continue; c.push_back(d[i]); } forinc(i,1,n-2) { int ret=press(s+c[0]+s+c[1]+c[2]+s+c[1]+c[0]+s+c[1]+c[1]); if(ret==(int)s.size()) s+=c[2]; else if(ret==(int)s.size()+1) s+=c[0]; else s+=c[1]; //cout<<fi<<"\n";; } if (s.size() != n) { r = press(s + c[0]); if (r == n) s = s + c[0]; else { r = press(s + c[1]); if (r == n) s = s + c[1]; else s = s + c[2]; } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |     if (s.size() != n)
      |         ~~~~~~~~~^~~~
combo.cpp:19:9: warning: unused variable 'cnt' [-Wunused-variable]
   19 |     int cnt=0;
      |         ^~~
combo.cpp:20:9: warning: unused variable 'num' [-Wunused-variable]
   20 |     int num=0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...