QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#252803#6394. Turn on the LightsupepapupuWA 0ms3376kbC++171.0kb2023-11-16 11:25:302023-11-16 11:25:31

Judging History

你现在查看的是最新测评结果

  • [2023-11-16 11:25:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3376kb
  • [2023-11-16 11:25:30]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cout << #x << ": " << x << el
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 5010, INF = 0x3f3f3f3f, mod = 998244353;

void inc(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

void dec(ll &a, ll b) {
    a -= b;
    if (a < 0) a += mod;
}

ll add(ll a, ll b) {
    a += b;
    return a >= mod ? a - mod : a;
}

ll del(ll a, ll b) {
    a -= b;
    return a < 0 ? a + mod : a;
}

int main() {
    // ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int l = 1, r = n, mid, last = 0;
    while (l < r) {
        mid = l + r >> 1;
        cout << "? " << mid << endl;
        int now; cin >> now;
        if (now == last) {
            cout << "! " << mid << endl;
            return 0;
        }
        if (now > last) l = mid + 1;
        else r = mid - 1;
        last = now;
    }
    cout << "! " << l << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3376kb

input:

3
1

output:

? 2
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3376kb

input:

10
1
2
3

output:

? 5
? 8
? 9
! 10

result:

wrong answer Wrong answer, more than 1 possible light!