Submission #132013

#TimeUsernameProblemLanguageResultExecution timeMemory
132013dvdg6566Combo (IOI18_combo)C++14
100 / 100
110 ms552 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; #define pb emplace_back #define mp make_pair #define ALL(x) x.begin(), x.end() #define SZ(x) (int)x.size() char ltrs[] = {'A', 'B', 'X', 'Y'}; vector<char> res; string q; string guess_sequence(int N) { // cres<<N<<'\n'; int a = press("AB"); int b = press("AX"); int x; if(a&&b)res.pb('A'); if (a&&!b)res.pb('B'); if (!a&&b)res.pb('X'); if(!a&&!b)res.pb('Y'); vector<char> V; for (int i=0;i<4;++i)if(ltrs[i] != res[0])V.pb(ltrs[i]); if (N==1){ string out = ""; for (auto i :res)out+=i;return out; } for (x=2;x<N;++x){ q = ""; for (auto i : res)q+=i; q += V[0]; q += V[0]; for (auto i : res)q+=i; q += V[0]; q += V[1]; for (auto i : res)q+=i; q += V[0]; q += V[2]; for (auto i : res)q+=i; q += V[1]; assert(SZ(q) <= 4*N); for (auto i : q)assert(i=='A'||i=='B'||i=='X'||i=='Y'); // cres<<q<<'\n';4 int r = press(q); // cres<<res<<' '<<x<<'\n'; if (r == x-1){ res.pb(V[2]); }else if (r == x+1){ res.pb(V[0]); }else{ res.pb(V[1]); } } // assert(SZ(res) + 1 == N); // cout<<x<<' '<<N<<' '<<SZ(res)<<'\n'; // assert(x<N); string ret = ""; for (auto i : res)ret += i; ret += V[0]; if (press(ret) == N)return ret; ret = ""; for (auto i : res)ret += i; ret += V[1]; if (press(ret) == N)return ret; ret = ""; for (auto i : res)ret += i; ret += V[2]; return ret; assert(0); }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |     for (auto i :res)out+=i;return out;
      |     ^~~
combo.cpp:26:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |     for (auto i :res)out+=i;return out;
      |                             ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...