답안 #336594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336594 2020-12-15T22:39:05 Z ljuba 콤보 (IOI18_combo) C++17
0 / 100
1 ms 200 KB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int n) {
    string ans;
    if(press("AB")) {
        if(press("A"))
            ans += 'A';
        else
            ans += 'B';
    } else if(press("X")) {
        ans += 'X';
    } else {
        ans += 'Y';
    }

    if(n <= 1)
        return ans;
    vector<char> kar;
    if(ans != "A")
        kar.push_back('A');
    if(ans != "B")
        kar.push_back('B');
    if(ans != "X")
        kar.push_back('X');
    if(ans != "Y");
        kar.push_back('Y');

    for(auto z : kar)
        cout << z << "\n";

    for(int i = 1; i < n-1; ++i) {
        string s = ans + kar[0] + ans + kar[1] + kar[0] + ans + kar[1] + kar[1] + ans + kar[1] + kar[2];
        cout << s << endl;
        int x = press(s) - i;
        if(x == 0) {
            ans += kar[2];
        } else if(x == 1) {
            ans += kar[0];
        } else {
            ans += kar[1];
        }
    }

    if(press(ans+kar[0]) == n) {
        ans += kar[0];
    } else if(press(ans+kar[1]) == n) {
        ans += kar[1];
    } else {
        ans += kar[2];
    }

    cout << ans << endl;

    return ans;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |     if(ans != "Y");
      |     ^~
combo.cpp:29:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |         kar.push_back('Y');
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Runtime error 1 ms 200 KB Execution failed because the return code was nonzero
6 Halted 0 ms 0 KB -