제출 #447552

#제출 시각아이디문제언어결과실행 시간메모리
447552MohamedAliSaidane콤보 (IOI18_combo)C++14
100 / 100
38 ms684 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; #define pb push_back #define popb pop_back #define ff first #define ss second const int MOD = 1e9 + 7; const ll INF = 1e18; string guess_sequence(int n) { char but[4] = {'A','B','X','Y'}; string p = ""; string s = ""; int fr = -1; bool ax = press("AX"); bool ay = press("AY"); if(ax && ay) { s = "A"; fr = 0; } else if(ax) { s = "X"; fr = 2; } else if(ay) { s = "Y"; fr = 3; } else { s= "B"; fr = 1; } but[3] = but[fr]; but[fr] = 'Y'; while(s.length() < n -1) { char b = but[0]; char x = but[1]; char y = but[2]; string g = s + b; g += (s+ x + x); g += (s+ x + b); g += (s+ x + y); int tent = press(g); if(tent == s.length() +1) { s += b; } else if(tent == s.length() + 2) { s += x; } else { s += y; } } if(s.length() < n) { for(int j = 0; j < 3; j ++) { string g = s + but[j]; int tent = press(g); if(tent == n) { s += but[j]; break; } else if( j == 1) { s += but[2]; break; } } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   while(s.length() < n -1)
      |         ~~~~~~~~~~~^~~~~~
combo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |      if(tent == s.length() +1)
      |         ~~~~~^~~~~~~~~~~~~~~~
combo.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |      else if(tent == s.length() + 2)
      |              ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:69:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   if(s.length() < n)
      |      ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...