Submission #1332873

#TimeUsernameProblemLanguageResultExecution timeMemory
1332873duskyDark Ride (EGOI25_darkride)C++20
16 / 100
30 ms840 KiB
#include <bits/stdc++.h>
using namespace std;

int n;

int find(vector<int> space) {
    if (space.size() == 1) return space[0];

    vector<bool> inq(n, 0); int mid = ((space.size()-1)/2);
    for (int i = 0; i <= mid; i++) inq[space[i]] = true;
    printf("? "); for (int i = 0; i < n; i++) printf("%d", inq[i] == true); printf("\n"); fflush(stdout);

    int x; scanf("%d", &x);
    vector<int> nextq;
    if (x%2) for (int i = 0; i <= mid; i++) nextq.push_back(space[i]);
    else for (int i = mid+1; i < space.size(); i++) nextq.push_back(space[i]);
    return find(nextq);
}

int main() {
    // freopen("in.txt", "r", stdin);

    scanf("%d", &n);
    vector<int> lh, rh;
    for (int i = 0; i < n/2; i++) lh.push_back(i);
    for (int i = n/2; i < n; i++) rh.push_back(i);
    printf("! %d %d\n", find(lh), find(rh)); fflush(stdout);
    // for (int i = 0; i <= 10; i++) {
    //     printf("? ");
    //     for (int j = 0; j < n; j++) printf("%d", (bool)(j & (1 << i)));
    //     printf("\n"); fflush(stdout);

    //     int x; scanf("%d", &x);
    //     if (x%2) {
    //         vector<int> lh, rh;
    //         for (int j = 0; j < n; j++) {
    //             if (j & (1 << i)) lh.push_back(j);
    //             else rh.push_back(j);
    //         } printf("! %d %d\n", find(lh), find(rh)); fflush(stdout);
    //         return 0;
    //     }
    // }
}

Compilation message (stderr)

Main.cpp: In function 'int find(std::vector<int>)':
Main.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     int x; scanf("%d", &x);
      |            ~~~~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...