제출 #1023374

#제출 시각아이디문제언어결과실행 시간메모리
1023374vanea콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; using ll = long long; string guess_sequence(int n) { vector<string> pos = {"A", "B", "X", "Y"}; string ans = ""; if(press("AB")) { if(press("A")) ans += "A"; else ans += "B"; } else { if(press("X")) ans += "X"; else ans += "Y"; } int last = 1; string res = string(1, ans[0]); for(int i = 1; i < n; i++) { if(i == n-1) { string curr = "", last1 = ""; for(auto it : pos) { if(it == res) continue; if(curr.length() == ans.length()+2) { last1 = ans+it; } else { curr += ans; curr += it; } } if(press(curr) == last+1) { string curr1 = ans + curr[ans.length()]; string curr2 = ans + curr[curr.length()-1]; if(press(curr1) == last+1) ans += curr[ans.length()]; else ans += curr[curr.length()-1]; } else { ans += last1[last1.length()-1]; } } else { string f = "", s = "", t = ""; for(auto it : pos) { if(it == res) continue; if(f == "") f = it; else if(s == "") s = it; else t = it; } string curr = ans + f + s + ans + f + f + ans + f + t + ans + s; int k = press(curr); if(k == last+2) { ans += f; } else if(k == last+1) { ans += s; } else ans += t; } ++last; } if(ans.length() != n) { while(1) } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |     if(ans.length() != n) {
      |        ~~~~~~~~~~~~~^~~~
combo.cpp:64:5: error: expected primary-expression before '}' token
   64 |     }
      |     ^