Submission #1350936

#TimeUsernameProblemLanguageResultExecution timeMemory
1350936phungmanager0Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define IS_INF(x)   (std::isinf(x))
#define IS_NAN(x)   (std::isnan(x))
#define fi   first
#define se   second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define div   ___div
#define prev   ___prev
#define next   ___next
#define left   ___leftc
#define right   ___right
#define TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define __Im_sogood__ main()
#define __builtin_popcount __builtin_popcountll
using namespace std;
const int MAXN = 2e5 + 5;
int n, a[MAXN];
int press(string p) {};
char getBeginChar() {
    int ans = press("AB"); if(ans > 0) {
        if(press("A") == 1) return 'A'; return 'B';
    }
    if(press("X") == 1) return 'X'; return 'Y';
}
string guess_sequence(int N) {
    char f = getBeginChar(); if(N == 1) return to_string(f); vector<string> againstChar;
    if('A' != f) againstChar.push_back("A");
    if('B' != f) againstChar.push_back("B");
    if('X' != f) againstChar.push_back("X");
    if('Y' != f) againstChar.push_back("Y"); string pre = ""; pre += f;
    int M = 0; REP(i, N - 2) {
        string mergeString = pre + againstChar[0] + pre +
        againstChar[1] + againstChar[0] + pre + againstChar[1] + againstChar[1] +
        pre + againstChar[1] + againstChar[2];
        M = (int)pre.size(); int answer = press(mergeString);
        if(answer == M + 1) pre += againstChar[0];
        else if(answer == M + 2) pre += againstChar[1]; else {
            pre += againstChar[2];
        }
    }
    // we need to search all of char to guess the last digit
    // n - 2 + 2
    // need to use 3 query to solve against
    REP(i, againstChar.size() - 1) {
        string mergeString = pre + againstChar[i]; if(press(mergeString) == N) {
            return mergeString;
        }
    }
    //cout << "before ans\n";
    //FORE(it, againstChar) cout << (*it) << endl;
    return pre + againstChar.back();
}
/*__Im_sogood__{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << guess_sequence(3);
    cerr << "Time elapsed: " << TIME << " s.\n";
    return 0;
}*/

Compilation message (stderr)

combo.cpp: In function 'int press(std::string)':
combo.cpp:25:22: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | int press(string p) {};
      |                      ^
/usr/bin/ld: /tmp/ccBVbTkv.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/ccnaAUnV.o:combo.cpp:(.text.unlikely+0x0): first defined here
collect2: error: ld returned 1 exit status