QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358525#6303. InversionJCY_WA 70ms17332kbC++141.5kb2024-03-19 20:32:222024-03-19 20:32:24

Judging History

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

  • [2024-03-19 20:32:24]
  • 评测
  • 测评结果:WA
  • 用时:70ms
  • 内存:17332kb
  • [2024-03-19 20:32:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128;
using u128 = unsigned __int128;
template <typename T>
void chkmax(T &x, const T &y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T &x, const T &y) {
  if (y < x) x = y;
}
constexpr int MAXN = 2010;
int n, p[MAXN], rev[MAXN], num[MAXN][MAXN];
bool query(int l, int r) {
  if (l == r) return false;
  cout << "? " << l << " " << r << endl;
  bool x;
  cin >> x;
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  p[1] = 1;
  rev[1] = 1;
  for (int i = 2; i <= n; ++i) {
    auto check = [&](int pos) {
      return query(pos, i) ^ (bool)num[pos][i - 1] ^ query(pos + 1, i) ^ num[pos + 1][i - 1];
    };
    int l = 1, r = i - 1, res = 0;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (!check(rev[mid])) {
        res = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    p[i] = res + 1;
    rev[res + 1] = i;
    for (int j = 1; j < i; ++j) {
      if (p[j] > res) {
        ++p[j];
        rev[p[j]] = j;
      }
    }
    for (int j = i - 1; j >= 1; --j)
      num[j][i] = num[j][i - 1] + num[j + 1][i] - num[j + 1][i - 1] + (p[j] > p[i]);
  }
  cout << "! ";
  for (int i = 1; i <= n; ++i) cout << p[i] << " \n"[i == n];
  cout << flush;
  return 0;
}
/*
g++ F.cpp -o F -std=c++14 -O2 -Wall -Wextra -Wshadow -g -fsanitize=address,undefined
*/

詳細信息

Test #1:

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

input:

3
0
0
1

output:

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

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 70ms
memory: 17332kb

input:

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

output:

? 1 2
? 1 3
? 2 3
? 2 3
? 2 4
? 3 4
? 3 4
? 2 5
? 3 5
? 1 5
? 2 5
? 2 6
? 3 6
? 5 6
? 1 6
? 2 6
? 1 7
? 2 7
? 5 7
? 6 7
? 1 8
? 2 8
? 5 8
? 6 8
? 7 8
? 6 9
? 7 9
? 2 9
? 3 9
? 1 9
? 2 9
? 9 10
? 8 10
? 9 10
? 5 10
? 6 10
? 6 11
? 7 11
? 2 11
? 3 11
? 9 11
? 10 11
? 11 12
? 2 12
? 3 12
? 9 12
? 10 12...

result:

wrong answer Wa.