Submission #930589

# Submission time Handle Problem Language Result Execution time Memory
930589 2024-02-20T07:33:16 Z Ghulam_Junaid Colors (BOI20_colors) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;

    bool verdict;
    if (n <= 6){
        cout << "? 1" << endl;
        cin >> verdict;

        int i = 2;
        int j = n;
        int turn = 1;
        int ans = n;
        while (i <= j){
            if (turn){
                cout << "? " << j << endl;
                j--;
                turn = 0;
            }
            else{
                cout << "? " << i << endl;
                i++;
                turn = 1;
            }
            cin >> verdict;
            if (verdict == 0)
                break;
            ans--;
        }

        cout << "= " << ans << endl;
        return 0;
    }

    int i = n / 4 + 1;
    int j = n - i + 1;
    cout << "? " << i << endl;
    cin >> verdict;
    cout << "? " << j << endl;
    cin >> verdict;
    
    if (verdict == 1){
        int ans = j - i;
        int turn = 1;
        while (i + 1 < j){
            if (turn){
                i++;
                cout << "? " << i << endl;
                cin >> verdict;
                turn = 0;
            }
            else{
                j--;
                cout << "? " << j << endl;
                cin >> verdict;
                turn = 1;
            }

            if (verdict == 0)
                break;
            ans--;
        }
        cout << ans << endl;
    }
    else{
        int ans = j - i;
        int turn = 1;
        while (i - turn > 0 and j + 1 - turn <= n){
            if (turn){
                i--;
                cout << "? " << i << endl;
                cin >> verdict;
                turn = 0;
            }
            else{
                j++;
                cout << "? " << j << endl;
                cin >> verdict;
                turn = 1;
            }

            if (verdict) break;
            ans++;
        }

        cout << ans + 1 << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -