Submission #243381

#TimeUsernameProblemLanguageResultExecution timeMemory
243381ant101Combo (IOI18_combo)C++14
100 / 100
41 ms644 KiB
#include "combo.h" #include <iostream> #include <algorithm> #include <cstring> #include <iomanip> #include <fstream> #include <cmath> #include <vector> #include <set> #include <unordered_set> #include <unordered_map> #include <map> #include <stack> #include <queue> #include <assert.h> #include <limits> #include <cstdio> #include <complex> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; #define mp make_pair #define f first #define s second typedef vector<int> vi; typedef vector<ll> vl; typedef vector<ld> vd; typedef vector<str> vs; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<pd> vpd; #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rall(x) (x).rbegin(), (x).rend() #define rsz resize #define ins insert #define ft front() #define bk back() #define pf push_front #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) const int MOD = 1e9+7; // 998244353; // = (119<<23)+1 const int MX = 2e5+5; const ll INF = 1e18; const ld PI = 4*atan((ld)1); const int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0}; std::string guess_sequence(int N) { std::string S = ""; std::string p = ""; vector<char> nf; if (press("AB")) { if (press("A")) { S+="A"; nf = {'B', 'X', 'Y'}; } else { S+="B"; nf = {'A', 'X', 'Y'}; } } else { if (press("X")) { S+="X"; nf = {'B', 'A', 'Y'}; } else { S+="Y"; nf = {'B', 'X', 'A'}; } } if (N == 1) { return S; } FOR (i, 2, N) { p = S+nf[0]+S+nf[1]+nf[0]+S+nf[1]+nf[1]+S+nf[1]+nf[2]; ll res = press(p); if (res == S.length()) { S+=nf[2]; } else if (res == S.length()+1) { S+=nf[0]; } else { S+=nf[1]; } } if (press(S+nf[0]) == N) { S+=nf[0]; } else if (press(S+nf[1]) == N) { S+=nf[1]; } else { S+=nf[2]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:95:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         if (res == S.length()) {
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:97:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |         } else if (res == S.length()+1) {
      |                    ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...