Submission #352101

#TimeUsernameProblemLanguageResultExecution timeMemory
352101SprdaloCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<double> vd; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<string> vs; typedef vector<pi> vp; typedef vector<pl> vpl; string pass; int N, cnt; int press(string s){ ++cnt; int n = N, m = s.length(); if (m > 4*n || m<0) throw SIGSEGV; int sol = 0; for (int i = 0; i < m; ++i){ int r = 0, ind = i; for (int j = 0; j < n; ++j){ if (s[ind] == pass[j]){ ++r; ++ind; } else { sol = max(sol, r); break; } } } return sol; } string guess_sequence(int n){ int k = press("AB"); char d; if (!k){ k = press("X"); if (!k) d = 'Y'; else d = 'X'; } else { k = press("A"); if (!k) d = 'B'; else d = 'A'; } string st = "ABXY"; if (d == 'A') st = "BXY"; else if (d == 'B') st = "AXY"; else if (d == 'X') st = "ABY"; else st = "ABX"; char a = st[0], b = st[1], c = st[2]; string s = ""; s += d; for (int i = 2; i < n; ++i){ string t = ""; t += (s + a + a); t += (s + a + b); t += (s + a + c); t += (s + b); // cout << "PITAM " << t << ' '; k = press(t); // cout << k << '\n'; if (k == i-1){ s += c; continue; } if (k == i){ s += b; continue; } s += a; } k = press(s+a); if (k == n){ s += a; return s; } k = press(s+b); if (k == n){ s += b; return s; } s += c; return s; } signed man() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); cin >> pass; N = pass.length(); cout << guess_sequence(N) << '\n'; cout << N << ' ' << cnt << '\n'; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccCAAeBW.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/ccMW3c0Z.o:combo.cpp:(.text+0xc0): first defined here
collect2: error: ld returned 1 exit status