Submission #1332855

#TimeUsernameProblemLanguageResultExecution timeMemory
1332855mamabearDark Ride (EGOI25_darkride)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <string>

using namespace std;

int ask(const string& s) {
    cout << "? " << s << endl;
    
    int screams;
    cin >> screams;
    return screams;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    if (!(cin >> n)) return 0; 

    int D = 0; 
    
    for (int k = 0; k < 15; ++k) {
        string s(n, '0');
        
        for (int i = 0; i < n; ++i) {
            if ((i >> k) & 1) {
                s[i] = '1';
            }
        }
        
        int screams = ask(s);
        
        if (screams % 2 != 0) {
            D |= (1 << k);
        }
    }

    int p = -1;
    for (int k = 0; k < 15; ++k) {
        if ((D >> k) & 1) {
            p = k;
            break;
        }
    }

    int A = (1 << p);
    
    for (int j = 0; j < 15; ++j) {
        if (j == p) continue;
        
        string s(n, '0');
        for (int i = 0; i < n; ++i) {
            if (((i >> p) & 1) && ((i >> j) & 1)) {
                s[i] = '1';
            }
        }
        
        int screams = ask(s);
        
        if (screams % 2 != 0) {
            A |= (1 << j);
        }
    }

    int B = A ^ D;
    cout << "! " << A << " " << B

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:67:34: error: expected ';' at end of input
   67 |     cout << "! " << A << " " << B
      |                                  ^
      |                                  ;
Main.cpp:67:34: error: expected '}' at end of input
Main.cpp:14:12: note: to match this '{'
   14 | int main() {
      |            ^