제출 #1011088

#제출 시각아이디문제언어결과실행 시간메모리
1011088SG2Alok콤보 (IOI18_combo)C++17
100 / 100
18 ms1728 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "combo.h" using namespace __gnu_pbds; using namespace std; #define ll long long #define fi first #define se second #define endl '\n' template <typename T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>; const ll MOD = 1e9 + 7; const ll INF = 1e18; int n; string guess_sequence(int n){ string p = "AB", s = ""; if(press(p)){ p = "A"; if(press(p)) s += p; else s += "B"; } else { p = "X"; if(press(p)) s += p; else s += "Y"; } if(n == 1) return s; vector<char> ch; if(s[0] != 'A') ch.push_back('A'); if(s[0] != 'B') ch.push_back('B'); if(s[0] != 'X') ch.push_back('X'); if(s[0] != 'Y') ch.push_back('Y'); while(s.length() + 2 <= n){ p = ""; for(int i = 0; i < 3; i++){ p += s; p += ch[0]; p += ch[i]; } p += s; p += ch[1]; int tmp = press(p); if(tmp == s.length() + 2){ s += ch[0]; } else if(tmp == s.length() + 1){ s += ch[1]; } else { s += ch[2]; } } p = ""; p += s; p += ch[0]; p += s; p += ch[1]; if(press(p) == n){ p = s + ch[0]; if(press(p) == n){ s += ch[0]; } else { s += ch[1]; } } else { s += ch[2]; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     while(s.length() + 2 <= n){
      |           ~~~~~~~~~~~~~~~^~~~
combo.cpp:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         if(tmp == s.length() + 2){
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         } else if(tmp == s.length() + 1){
      |                   ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...