Submission #241311

#TimeUsernameProblemLanguageResultExecution timeMemory
241311WhaleVomitCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define sz(v) (int)v.size() #define MOO(i, a, b) for(int i=a; i<b; i++) #define M00(i, a) for(int i=0; i<a; i++) #define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--) #define M00d(i,a) for(int i = (a)-1; i>=0; i--) #define FAST ios::sync_with_stdio(0); cin.tie(0); #define finish(x) return cout << x << '\n', 0; #define dbg(x) cerr << ">>> " << #x << " = " << x << "\n"; #define _ << " _ " << typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef pair<ld,ld> pd; typedef complex<ld> cd; string cur; int press(string p) { int cnt = 0; int mx = 0; for(char c: p) { if(cnt >= sz(cur)) return sz(cur); if(cur[cnt] == c) cnt++; else cnt = 0; mx = max(mx, cnt); } return mx; } string guess_sequence(int n) { vector<string> chars; chars.pb("A"); chars.pb("B"); chars.pb("X"); chars.pb("Y"); string firstChar = ""; if(press("AB")) { if(press("A")) firstChar = "A"; else firstChar = "B"; } else { if(press("X")) firstChar = "X"; else firstChar = "Y"; } if(n == 1) return firstChar; vector<string> otherChars; M00(i, 4) if(chars[i] != firstChar) otherChars.pb(chars[i]); string res = firstChar; M00(i, n-2) { string ask = ""; ask += res + otherChars[0]; ask += res + otherChars[1] + otherChars[0]; ask += res + otherChars[1] + otherChars[1]; ask += res + otherChars[1] + otherChars[2]; int x = press(ask); if(x == sz(res)) res += otherChars[2]; else if(x == sz(res)+1) res += otherChars[0]; else res += otherChars[1]; } if(press(res+otherChars[0]) == n) res += otherChars[0]; else if(press(res+otherChars[1]) == n) res += otherChars[1]; else res += otherChars[2]; return res; } string runtest(string s) { cur = s; return guess_sequence(sz(s)); } int main() { FAST vector<string> tests; tests.pb("ABXYY"); tests.pb("A"); tests.pb("B"); tests.pb("X"); tests.pb("Y"); tests.pb("AB"); tests.pb("XB"); tests.pb("YA"); tests.pb("ABBBXXYXX"); for(string s: tests) { if(s == runtest(s)) { cout << "OK\n"; } else { cout << "BAD\n"; } } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccCRfOAw.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccjK1ldx.o:combo.cpp:(.text+0x180): first defined here
/usr/bin/ld: /tmp/ccCRfOAw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjK1ldx.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status