Submission #1103991

#TimeUsernameProblemLanguageResultExecution timeMemory
1103991asdfghjkCombo (IOI18_combo)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(), x.end() #define F first #define ld long double #define S second using namespace std; const ll N = 5e3 + 5; const ll NN = 4e5 + 5; const ll INF = 1e18; const ll inf = 1e9; const ll MOD = 1e9 + 7; char a[10]; int was[10]; string z[15]; int press(std::string p); string find_first(){ string d = ""; d += a[1]; if(press(d) == 1){ a[1] = a[2]; a[2] = a[3]; a[3] = a[4]; return d; } d.pop_back(); d += a[2]; if(press(d) == 1){ a[2] = a[3]; a[3] = a[4]; return d; } d.pop_back(); d += a[3]; if(press(d) == 1){ a[3] = a[4]; return d; } d.pop_back(); d += a[4]; if(press(d) == 1){ return d; } d.pop_back(); } string guess_sequence(int n){ a[1] = 'A'; a[2] = 'B'; a[3] = 'X'; a[4] = 'Y'; string s = find_first(); int val = 1; for(int i = 2;i <= n;i++){ if(val > i)continue; string d = s; d += a[1]; d += a[2]; int res = press(d); if(res == val){ s += a[3]; val = i; } else if(res == val + 2){ s = d; val = res; } else{ d.pop_back(); d += a[1]; res = press(d); if(res == val){ s += a[2]; } else if(res == val + 1){ d.pop_back(); d += a[3]; s = a[3]; } else{ s = d; } val = s.size(); } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string find_first()':
combo.cpp:45:15: warning: control reaches end of non-void function [-Wreturn-type]
   45 |     d.pop_back();
      |     ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...