제출 #772575

#제출 시각아이디문제언어결과실행 시간메모리
772575_martynas콤보 (IOI18_combo)C++11
5 / 100
1 ms208 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; /* Let known prefix be $ and first letter is A press: $B + $XX + $XB + $XY if this string returns |$|+1 then $ = $+'B' else if this string returns |$|+2 then $ = $+'X' else $ = $+'Y' */ string guess_sequence(int N) { string p = "AB"; string S = ""; vector<char> C = {'A', 'B', 'X', 'Y'}; if(press(p)) { p = "A"; if(press(p)) S = "A"; else S = "B"; } else { p = "X"; if(press(p)) S = "X"; else S = "Y"; } for(int i = 0; i < N-2; i++) { p = ""; string temp = ""; for(char c : C) { if(c == S[0]) continue; if(p == "") { p = S; p += c; temp += c; } else if(p.size() == S.size()+1) { for(char cc : C) { if(cc == S[0]) continue; p += S; p += c; p += cc; } temp += c; } else { temp += c; } } if(press(p) == S.size()+1) { S += temp[0]; } else if(press(p) == S.size()+2) { S += temp[1]; } else { S += temp[2]; } } int cnt = 0; for(char c : C) { if(c == S[0]) continue; cnt++; if(cnt == 3) { S += c; } else { p = S; p += c; if(press(p) == N) { S += c; break; } } } return S; } /* ABXYY ABXBA + ABXXBA + ABXXXA + ABXXXYA with N queries find N - 2 characters with 2 queries find 2 last characters? */

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(press(p) == S.size()+1) {
      |            ~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:51:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         else if(press(p) == S.size()+2) {
      |                 ~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...