답안 #777734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777734 2023-07-09T14:37:22 Z dxz05 Mađioničar (COI22_madionicar) C++17
0 / 100
1329 ms 300 KB
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define MP make_pair
//#define endl '\n'

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3e2;

int queries;
string hidden_string;

int ask(int l, int r){
    queries++;

    if (!hidden_string.empty()){
        string t = hidden_string.substr(l, r - l + 1);
        string rt = string(rall(t));
        return t == rt;
    }

    cout << "? " << l + 1 << ' ' << r + 1 << endl;
    int res;
    cin >> res;
    return res;
}

void solve(){
//    hidden_string = "neven";

    int n;
    if (hidden_string.empty()){
        cin >> n;
    } else {
        n = (int) hidden_string.size();
    }

    int odd = 3;
    for (int i = 0; i < n; i++){
        while (true){
            int l = i - odd / 2, r = i + odd / 2;
            if (0 <= l && r < n && ask(l, r)){
                odd += 2;
            } else {
                break;
            }
        }
    }

    int even = 2;
    for (int i = 0; i < n; i++){
        while (true){
            int l = i - even / 2 + 1, r = i + even / 2;
            if (0 <= l && r < n && ask(l, r)){
                even += 2;
            } else {
                break;
            }
        }
    }

    cerr << "Queries -> " << queries << endl;

}

int main(){
    clock_t startTime = clock();
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int test_cases = 1;
//    cin >> test_cases;

    for (int test = 1; test <= test_cases; test++){
        // cout << (solve() ? "YES" : "NO") << endl;
        solve();
    }

#ifdef LOCAL
    cerr << "Time: " << int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl;
#endif

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:78:13: warning: unused variable 'startTime' [-Wunused-variable]
   78 |     clock_t startTime = clock();
      |             ^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 300 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 300 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1329 ms 300 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 300 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -