제출 #1104619

#제출 시각아이디문제언어결과실행 시간메모리
1104619anmattroi콤보 (IOI18_combo)C++14
100 / 100
30 ms1644 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; //ABXY string guess_sequence(int N) { string p = ""; int p1 = press("AB"), p2; switch (p1) { case 2: p = "AB"; break; case 1 : p2 = press("A"); if (p2 == 0) p = "B"; else p = "A"; break; case 0 : p2 = press("X"); if (p2 == 0) p = "Y"; else p = "X"; break; } while (p.size() < N-1) { string T; switch (p[0]) { case 'A' : T = p + "BB" + p + "BX" + p + "BY" + p + "X"; p1 = press(T) - p.size(); if (p1 == 2) p.push_back('B'); else if (p1 == 1) p.push_back('X'); else p.push_back('Y'); break; case 'B' : T = p + "AA" + p + "AX" + p + "AY" + p + "X"; p1 = press(T) - p.size(); if (p1 == 2) p.push_back('A'); else if (p1 == 1) p.push_back('X'); else p.push_back('Y'); break; case 'X' : T = p + "AA" + p + "AB" + p + "AY" + p + "B"; p1 = press(T) - p.size(); if (p1 == 2) p.push_back('A'); else if (p1 == 1) p.push_back('B'); else p.push_back('Y'); break; case 'Y' : T = p + "AA" + p + "AB" + p + "AX" + p + "B"; p1 = press(T) - p.size(); if (p1 == 2) p.push_back('A'); else if (p1 == 1) p.push_back('B'); else p.push_back('X'); } } if (p.size() == N) return p; switch (p[0]) { case 'A' : p1 = press(p + "B" + p + "X") - p.size(); if (p1 == 1) { p2 = press(p + "B") - p.size(); if (p2 == 1) p.push_back('B'); else p.push_back('X'); } else p.push_back('Y'); break; case 'B' : p1 = press(p + "A" + p + "X") - p.size(); if (p1 == 1) { p2 = press(p + "A") - p.size(); if (p2 == 1) p.push_back('A'); else p.push_back('X'); } else p.push_back('Y'); break; case 'X' : p1 = press(p + "A" + p + "B") - p.size(); if (p1 == 1) { p2 = press(p + "A") - p.size(); if (p2 == 1) p.push_back('A'); else p.push_back('B'); } else p.push_back('Y'); break; case 'Y' : p1 = press(p + "A" + p + "B") - p.size(); if (p1 == 1) { p2 = press(p + "A") - p.size(); if (p2 == 1) p.push_back('A'); else p.push_back('B'); } else p.push_back('X'); break; } return p; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     while (p.size() < N-1) {
      |            ~~~~~~~~~^~~~~
combo.cpp:59:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |     if (p.size() == N) return p;
      |         ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...