Submission #1006656

#TimeUsernameProblemLanguageResultExecution timeMemory
1006656devariaota콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

# define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"

std::string guess_sequence(int N) {
    char ch[3];
    string st;
    int asd = press("AB");
    if(asd) {
        int x = press("A");
        if(x) st = "A", ch = {'B', 'X', 'Y'};
        else st = "B", ch = {'A', 'X', 'Y'};
    }
    else {
        int x = press("X");
        if(x) st = "X", ch = {'A', 'B', 'Y'};
        else st = "Y", ch = {'A', 'B', 'X'};
    }

    for(int i = 2; i<N; i++) {
        string now = "";
        now += st; now.pb(ch[0]); now.pb(ch[0]);
        now += st; now.pb(ch[0]); now.pb(ch[1]);
        now += st; now.pb(ch[0]); now.pb(ch[2]);
        now += st; now.pb(ch[1]);
        int get = press(now);
        if(get == i+1) st.pb(ch[0]);
        else if(get == i) st.pb(ch[1]);
        else st.pb(ch[2]);
    }

    string  st0 = st; st0.pb(ch[0]);
    string  st1 = st; st1.pb(ch[1]);
    string  st2 = st; st2.pb(ch[2]);

    int x = press(st0);
    int y = press(st1);
    int z = press(st2);

    if(x == N) st.pb(ch[0]);
    else if(y == N) st.pb(ch[1]);
    else st.pb(ch[2]);

    return st;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(long long int)':
combo.cpp:17:28: error: assigning to an array from an initializer list
   17 |         if(x) st = "A", ch = {'B', 'X', 'Y'};
      |                         ~~~^~~~~~~~~~~~~~~~~
combo.cpp:18:27: error: assigning to an array from an initializer list
   18 |         else st = "B", ch = {'A', 'X', 'Y'};
      |                        ~~~^~~~~~~~~~~~~~~~~
combo.cpp:22:28: error: assigning to an array from an initializer list
   22 |         if(x) st = "X", ch = {'A', 'B', 'Y'};
      |                         ~~~^~~~~~~~~~~~~~~~~
combo.cpp:23:27: error: assigning to an array from an initializer list
   23 |         else st = "Y", ch = {'A', 'B', 'X'};
      |                        ~~~^~~~~~~~~~~~~~~~~
combo.cpp:44:9: warning: unused variable 'z' [-Wunused-variable]
   44 |     int z = press(st2);
      |         ^