QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470407#6394. Turn on the LightUESTC_OldEastWest#WA 1ms3684kbC++17761b2024-07-10 12:55:172024-07-10 12:55:17

Judging History

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

  • [2024-07-10 12:55:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2024-07-10 12:55:17]
  • 提交

answer

#include <bits/stdc++.h>
using ll = long long;

void charming() {
  int n; std::cin >> n;
  
  auto send = [](int x) -> int {
    std::cout << "? " << x << std::endl;
    std::cout.flush();
    int ret; std::cin >> ret;
    return ret;
  };

  auto answer = [](int x) -> void {
    std::cout << "! " << x << std::endl;
    std::cout.flush();
  };

  int l = 1, r = n, k = 1, diff = 0;
  while (l <= r) {
    int mid = l + r >> 1;
    int ret = send(mid);
    if (ret == diff) {k = mid; break;}
    else if (ret > diff) l = mid + 1;
    else r = mid - 1;
    diff = ret;
  }
  
  answer(k);
}

signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  charming();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3684kb

input:

10
1
2
3
4

output:

? 5
? 8
? 9
? 10
! 1

result:

wrong answer Wrong answer, more than 1 possible light!