QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745776#9432. PermutationguosounRE 0ms3828kbC++171.9kb2024-11-14 11:31:382024-11-14 11:31:38

Judging History

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

  • [2024-11-14 11:31:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3828kb
  • [2024-11-14 11:31:38]
  • 提交

answer

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

struct ia {
  int query(std::vector<int> a) {
    std::cout << 0 << ' ';
    for (int i : a) std::cout << i << ' ';
    std::cout << std::endl;
    int ret;
    std::cin >> ret;
    return ret;
  }
  void answer(std::vector<int> a) {
    std::cout << 1 << ' ';
    for (int i : a) std::cout << i << ' ';
    std::cout << std::endl;
  }
} ia;

int main() {
  std::cin.tie(0)->sync_with_stdio(0);
  int n;
  std::cin >> n;
  if (n == 1) return ia.answer({1}), 0;
  std::vector<int> a(n);
  auto solve = [&](auto &self, int l, int r, std::vector<int> v) {
    assert((int)v.size() == r - l + 1);
    if (l == r) return a[l] = v[0], void();
    int mid = (l + r) >> 1;
    std::vector<std::vector<int>> cv;
    std::vector<int> lv, rv;
    for (int i : v) cv.push_back({i});
    while (cv.size()) {
      if (cv.size() == 1) {
        auto a = cv[0];
        cv.pop_back();
        int v = a[0];
        std::vector<int> q(n, !(v - 1) ? v + 1 : v - 1);
        for (int i = l; i <= mid; i++) q[i] = v;
        if (ia.query(q)) lv.insert(lv.end(), a.begin(), a.end());
        else rv.insert(rv.end(), a.begin(), a.end());
        continue;
      }
      auto a = cv.back();
      cv.pop_back();
      auto b = cv.back();
      cv.pop_back();
      std::vector<int> q(n, a[0]);
      for (int i = mid + 1; i <= r; i++) q[i] = b[0];
      if (int t = ia.query(q); t == 1) {
        a.insert(a.end(), b.begin(), b.end());
        cv.push_back(a);
      } else if (t == 2) {
        lv.insert(lv.end(), a.begin(), a.end());
        rv.insert(rv.end(), b.begin(), b.end());
      } else {
        lv.insert(lv.end(), b.begin(), b.end());
        rv.insert(rv.end(), a.begin(), a.end());
      }
    }
    self(self, l, mid, lv);
    self(self, mid + 1, r, rv);
  };
  std::vector<int> v(n);
  std::iota(v.begin(), v.end(), 1);
  solve(solve, 0, n - 1, v);
  ia.answer(a);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3828kb

input:

5
0
1
2
0
1
0
2

output:

0 5 5 5 4 4 
0 3 3 3 2 2 
0 3 3 3 1 1 
0 2 2 3 2 2 
0 4 4 3 3 3 
0 4 3 4 4 4 
0 1 1 1 1 5 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: -100
Runtime Error

input:

1000
2
1
1
1
0
1
1
0
1
1
0
2
1
0
1
2
1
1
1
2
1
1
2
1
2
1
1
1
2
2
2
2
1
0
0
1
1
2
2
0
1
1
0
0
0
0
1
0
1
2
2
1
2
1
1
1
2
0
0
2
1
2
0
1
2
0
0
1
0
0
2
0
0
0
2
0
1
0
1
0
2
1
1
1
0
1
1
1
2
1
1
0
2
1
0
0
1
0
0
1
2
0
0
1
1
1
2
0
1
1
1
0
1
1
1
1
2
1
0
1
1
2
1
1
0
1
1
0
1
1
1
1
1
1
1
1
0
0
0
1
1
2
0
1
2
0
0
2...

output:

0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...

result: