QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#104720#6394. Turn on the Lightgapinho#WA 4ms3560kbC++201018b2023-05-11 19:46:462023-05-11 19:46:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-11 19:46:50]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3560kb
  • [2023-05-11 19:46:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = __int128_t;

#define int long long

using ii = pair<int, int>;

// #define endl '\n'

const int ms = 505;

int query(int x) {
  cout << "? " << x << endl;
  int y;
  cin >> y;
  return y;
}

void go(int i){
  cout << "! " << i << endl;
  exit(0); 
}

void solve() {
  int n;
  cin >> n;
  for(int i = 1; i <= min(n, 20ll); i++) {
    int ans = query(i);
    if(ans != i) {
      go(i);
    }
  }
  int num = 20;
  int lo = 21, hi = n;
  while(lo != hi) {
    int mi = (lo+hi)/2;
    int k = query(mi);
    if(k == num) {
      lo = mi;
      hi = mi;
    } else if(k > num) {
      lo = mi+1;
    } else {
      hi = mi - 1;
    }
  }
  go(lo);
}

int32_t main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cout << fixed << setprecision(9);
    int testes = 1;
    // cin >> testes;
    int test = 0;

    while(testes--) {
      // cout << "Case #" << (++test) << ": ";
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3368kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

10
1
2
3
4
5
6
7
8
8

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

9
1
2
3
4
5
6
7
7

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
! 8

result:

ok Correct position at 8

Test #4:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

8
1
2
3
4
5
6
6

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

score: 0
Accepted
time: 1ms
memory: 3388kb

input:

7
1
2
3
4
5
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
! 6

result:

ok Correct position at 6

Test #6:

score: 0
Accepted
time: 2ms
memory: 3388kb

input:

6
1
2
3
4
5
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
! 6

result:

ok Correct position at 6

Test #7:

score: 0
Accepted
time: 2ms
memory: 3388kb

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

score: 0
Accepted
time: 2ms
memory: 3396kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Wrong Answer
time: 4ms
memory: 3404kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
22
21
20

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 15
? 16
? 17
? 18
? 19
? 20
? 500010
? 750005
? 875003
? 937502
? 968751
? 984376
! 984376

result:

wrong answer Wrong answer, more than 1 possible light!