Submission #486468

#TimeUsernameProblemLanguageResultExecution timeMemory
486468ssenseCombo (IOI18_combo)C++14
100 / 100
37 ms580 KiB
#include <bits/stdc++.h> #include "combo.h" #define startt ios_base::sync_with_stdio(false);cin.tie(0); typedef long long ll; using namespace std; #define vint vector<int> #define all(v) v.begin(), v.end() #define MOD 1000000007 #define MOD2 998244353 #define MX 1000000000 #define MXL 1000000000000000000 #define PI (ld)2*acos(0.0) #define nax 200005 #define pb push_back #define sc second #define fr first //#define int long long #define endl '\n' #define ld long double #define NO cout << "NO" << endl #define YES cout << "YES" << endl /* namespace { constexpr int MAX_N = 2000; constexpr int MAX_NUM_MOVES = 8000; int N; std::string S; int num_moves; void wrong_answer(const char *MSG) { printf("Wrong Answer: %s\n", MSG); exit(0); } } // namespace int press(std::string p) { if (++num_moves > MAX_NUM_MOVES) { wrong_answer("too many moves"); } int len = p.length(); if (len > 4 * N) { wrong_answer("invalid press"); } for (int i = 0; i < len; ++i) { if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') { wrong_answer("invalid press"); } } int coins = 0; for (int i = 0, j = 0; i < len; ++i) { if (j < N && S[j] == p[i]) { ++j; } else if (S[0] == p[i]) { j = 1; } else { j = 0; } coins = std::max(coins, j); } return coins; } */ string guess_sequence(int n) { string s; vector<char> a(4); a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y'; int k; char exclude; if(press("AB") >= 1) { if(press("A") >= 1) { exclude = 'A'; } else { exclude = 'B'; } } else { if(press("X") >= 1) { exclude = 'X'; } else { exclude = 'Y'; } } s.pb(exclude); a.erase(find(all(a), exclude)); for(int i = 0; i < n-2; i++) { string now = s; now+=a[0]; now+=a[0]; now+=s; now+=a[0]; now+=a[1]; now+=s; now+=a[0]; now+=a[2]; now+=s; now+=a[1]; k = press(now); if(k == s.size()+2) { s.pb(a[0]); continue; } if(k == s.size()+1) { s.pb(a[1]); continue; } if(k == s.size()) { s.pb(a[2]); } } if(s.size() < n) { if(press(s+a[0]) == s.size()+1) { s+=a[0]; } else if(press(s+a[1]) == s.size()+1) { s+=a[1]; } else { s+=a[2]; } } return s; } /* int main() { char buffer[MAX_N + 1]; if (scanf("%s", buffer) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } S = buffer; N = S.length(); num_moves = 0; std::string answer = guess_sequence(N); if (answer != S) { wrong_answer("wrong guess"); exit(0); } printf("Accepted: %d\n", num_moves); return 0; return 0; } */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:112:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |   if(k == s.size()+2)
      |      ~~^~~~~~~~~~~~~
combo.cpp:117:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |   if(k == s.size()+1)
      |      ~~^~~~~~~~~~~~~
combo.cpp:122:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |   if(k == s.size())
      |      ~~^~~~~~~~~~~
combo.cpp:127:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  127 |  if(s.size() < n)
      |     ~~~~~~~~~^~~
combo.cpp:129:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  129 |   if(press(s+a[0]) == s.size()+1)
      |      ~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:133:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  133 |   else if(press(s+a[1]) == s.size()+1)
      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...