結果

問題 No.3592 I Love LIS
コンテスト
ユーザー Kude
提出日時 2026-07-17 22:16:49
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,150 ms / 8,000 ms
+ 12µs
コード長 1,863 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,342 ms
コンパイル使用メモリ 357,992 KB
実行使用メモリ 5,888 KB
平均クエリ数 4556.81
最終ジャッジ日時 2026-07-17 22:17:18
合計ジャッジ時間 21,363 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI ord(n);
  rep(i, n) ord[i] = i;
  bool found = false;
  rep(i, n) {
    cout << "?";
    rep(j, n) cout << ' ' << int(i == j);
    cout << endl;
    int res;
    cin >> res;
    if (res == 1) {
      swap(ord[i], ord[0]);
      found = true;
    }
  }
  assert(found);
  auto cmp = [&](int i, int j) {
    static VI a;
    a.assign(n, 0);
    a[i] = 1;
    a[j] = 2;
    cout << "?";
    rep(j, n) cout << ' ' << a[j];
    cout << endl;
    int res;
    cin >> res;
    return res == 3;
  };
  auto dfs = [&](auto&& self, int l, int r) -> void {
    if (r - l == 1) return;
    int c = (l + r) / 2;
    self(self, l, c);
    self(self, c, r);
    static VI d1, d2;
    d1.assign(ord.begin() + l, ord.begin() + c);
    d2.assign(ord.begin() + c, ord.begin() + r);
    auto itw = ord.begin() + l;
    auto it2 = d2.begin();
    for (int i : d1) {
      while (it2 != d2.end() && cmp(*it2, i)) {
        *itw++ = *it2++;
      }
      *itw++ = i;
    }
  };
  dfs(dfs, 1, n);
  cout << "! ";
  rep(i, n) cout << ord[i] + 1 << " \n"[i + 1 == n];
}
0