QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#600722#6303. Inversionucup-team3691#WA 80ms6744kbC++141.9kb2024-09-29 18:33:152024-09-29 18:33:15

Judging History

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

  • [2024-09-29 18:33:15]
  • 评测
  • 测评结果:WA
  • 用时:80ms
  • 内存:6744kb
  • [2024-09-29 18:33:15]
  • 提交

answer

#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <random>
#include <ctime>
#include <cstdlib>
#include <chrono>

using namespace std;

map<pair<int, int>, int> f;
int query(int l, int r) {
  if (f.count({l, r})) {
    return f[{l, r}];
  }

  if (l == r) {
    return 0;
  }

  cout << "? " << l << " " << r << endl;
  cin >> f[{l, r}];
  return f[{l, r}];
}

int comp(int l, int r) {
  if (r - l == 1) {
    return query(l, r);
  }

  int st = query(l, r - 1);
  int dr = query(l + 1, r);
  int all = query(l, r);
  int mid = query(l + 1, r - 1);

  return st ^ dr ^ all ^ mid; 
}

vector<int> divide(int l, int r) {
  if (l == r) {
    return {1};
  }

  if (l == r - 1) {
    if (comp(l, r) == 0) {
      return {1, 2};
    } else {
      return {2, 1};
    }
  }

  int m = (l + r) / 2;
  auto st = divide(l, m);
  auto dr = divide(m + 1, r);

  map<int, int> fs, fd;
  for (int i = 0; i < st.size(); ++i) {
    fs[st[i]] = i;
  }
  
  for (int i = 0; i < dr.size(); ++i) {
    fd[dr[i]] = i + st.size();
  }

  vector<int> v(r - l + 1);

  int i = 1, j = 1, k = 1;
  while (i <= st.size() && j <= dr.size()) {
    if (comp(fs[i] + l, fd[j] + l) == 0) {
      v[fs[i++]] = k++;
    } else {
      v[fd[j++]] = k++;
    }
  }

  while (i <= st.size()) {
    v[fs[i++]] = k++;
  }

  while (j <= dr.size()) {
    v[fd[j++]] = k++;
  }

  return v;
}

void solve() {
  int n;
  cin >> n;

  auto v = divide(1, n);

  cout << "! ";
  for (auto it : v) {
    cout << it << " ";
  }

  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
  //cin >> t;
  while (t--)
    solve();

  return 0;
}

詳細信息

Test #1:

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

input:

3
0
1
0

output:

? 1 2
? 2 3
? 1 3
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 80ms
memory: 6744kb

input:

1993
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
0
0
0
0
1
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
0
1
0
1
1
1
0
1
1
0
1
1
0
1
1
1
1
1
0
0
1
0
1
0
1
1
1
0
1
0
0
0
0
0
1
0
1
0
1
0
0
0
0
1
1
1
0
1
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
0
1
0
0
1
0
1...

output:

? 1 2
? 3 4
? 2 3
? 1 3
? 5 6
? 7 8
? 6 7
? 5 7
? 6 8
? 5 8
? 1 6
? 2 7
? 1 7
? 2 6
? 1 4
? 2 5
? 1 5
? 2 4
? 2 8
? 1 8
? 3 8
? 3 7
? 4 8
? 4 7
? 9 10
? 11 12
? 10 11
? 9 11
? 10 12
? 9 12
? 13 14
? 15 16
? 14 15
? 13 15
? 14 16
? 13 16
? 10 13
? 11 14
? 10 14
? 11 13
? 12 14
? 12 13
? 12 15
? 11 15...

result:

wrong output format Unexpected end of file - int32 expected