QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#594016#7804. Intersegment ActivationStrausKoldunWA 0ms3556kbC++171.3kb2024-09-27 18:04:402024-09-27 18:04:40

Judging History

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

  • [2024-09-27 18:04:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-09-27 18:04:40]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

unsigned int grayencode(unsigned int g) 
{
    return g ^ (g >> 1);
}

int diff(unsigned int a, unsigned int b){
  // cout << "diff" << a << " " << b << endl;
  auto c = a ^ b;
  int res = 0;
  while(c != 1){
    assert(c % 2 != 1);
    c /= 2;
    res++;
  }
  return res;
}

int zapr(int l, int r){
  cout << l << " " << r << endl;
  int x;
  cin >> x;
  return x;
}

void solve() {
  int n;
  cin >> n;
  int now;
  cin >> now;
  int low = 1, high = n;
  while (n)
  {
    int prev_code = grayencode(0);
    for (int i = 1; i < (1 << n); i++)
    {
      // cout << "i: " << i << endl;
      // cout << "1<<n: " << (1 << n) << endl;
      int now_code = grayencode(i);
      int new_now = zapr(low, low + diff(prev_code, now_code));
      // cout << "now: " << now << endl;
      // cout << "new_now:" << new_now << endl;
      if(new_now != now){
        if(new_now < now){
          new_now = zapr(low, low + diff(prev_code, now_code));
          
        }
        now = new_now;
        break;
      }
      prev_code = now_code;
    }
    low++;
    n--;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
//   cin >> t;
  while (t--) {
    solve();
  }
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3556kb

input:

3
0
0
0
1
1
2
1
2

output:

1 1
1 2
1 1
2 2
2 3
3 3
3 3

result:

wrong answer format  Unexpected end of file - int32 expected