제출 #139460

#제출 시각아이디문제언어결과실행 시간메모리
139460Meloric콤보 (IOI18_combo)C++14
5 / 100
2 ms424 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){ //cout << pos << "pos"<<'\n'; 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; } //cout << pos; 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'; assert(known.size()==N-1); if(press(known+pos[0])==N){ //assert(known.size()+1 == N); return known+pos[0]; } if(press(known+pos[1])==N){ //assert(known.size()+1 == N); return known+pos[1]; } //assert(known.size()+1 == N); return known+pos[2]; }

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

combo.cpp: In function 'char beg(std::string)':
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i< pos.size()/2; i++){
      |                    ~^~~~~~~~~~~~~~
combo.cpp:35:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i = pos.size()/2; i < pos.size(); i++){
      |                                   ~~^~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |   assert(known.size()==N-1);
      |          ~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...