제출 #139456

#제출 시각아이디문제언어결과실행 시간메모리
139456Meloric콤보 (IOI18_combo)C++14
0 / 100
2 ms296 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; int turn(string known, string pos){ string a = ""; for(char b : known){ a+=b; } a+=pos[1]; for(int i = 0; i< 3; i++){ for(char b : known){ a+= b; } a+=pos[2]; a+=pos[i]; } //cout << a << '\n'; return press(a); } char beg(string pos){ if(pos.size()==1)return pos[0]; string a = ""; for(int i = 0; i< pos.size()/2; i++){ a += pos[i]; } //cout << a << '\n'; int num = press(a); if(num > 0){ return beg(a); }else{ string b = ""; for(int i = pos.size()/2; i < pos.size(); i++){ b+=pos[i]; return beg(b); } } } string guess_sequence(int N) { string but = "ABXY"; string known = ""; known+=beg(but); string pos =""; for(auto c : but){ if(c == known[0])continue; pos+=c; } for(int i = 1; i< N-1; i++){ int ans = turn(known, pos); int tmp = ans-known.size(); if(tmp == 0)known+=pos[0]; if(tmp == 1)known+=pos[1]; if(tmp == 2)known+=pos[2]; } //cout << known+pos[0]<<'\n'; //cout << known+pos[1]<<'\n'; if(press(known+pos[0])==N)return known+pos[0]; if(press(known+pos[1])==N)return known+pos[1]; return known+pos[2]; }

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

combo.cpp: In function 'char beg(std::string)':
combo.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i = 0; i< pos.size()/2; i++){
      |                    ~^~~~~~~~~~~~~~
combo.cpp:34:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = pos.size()/2; i < pos.size(); i++){
      |                                   ~~^~~~~~~~~~~~
combo.cpp:24:16: warning: control reaches end of non-void function [-Wreturn-type]
   24 |     string a = "";
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...