結果

問題 No.3737 Quiz Time
コンテスト
ユーザー kukone
提出日時 2026-09-19 17:50:52
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 174 ms / 2,000 ms
+ 0µs
コード長 1,129 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,651 ms
コンパイル使用メモリ 378,340 KB
実行使用メモリ 10,044 KB
平均クエリ数 84.22
最終ジャッジ日時 2026-09-19 17:51:05
合計ジャッジ時間 6,578 ms
ジャッジサーバーID
(参考情報)
judge2_0 / <nil>
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using P=pair<ll,ll>;
typedef atcoder::modint mint;
ll inf=9e18;
template<typename T, int s, int i = 0>
auto vec(const ll (&sizes)[s], const T& init = T()){
  if constexpr(i < s) return vector(sizes[i], vec<T, s, i+1>(sizes, init));
  else return init;
}


int main(){
  ll p,x;
  cin>>p;
  auto v=vec<ll>({p},0);
  auto w=vec<ll>({p},0);
  auto v2=vec<ll>({p},0);
  auto w2=vec<ll>({p},0);
  for(ll i=0;i<p-1;i++){
    printf("? %lld %lld\n",i+1,i+1);
    cin>>x;
    x--;
    v[i]=x%p;
    w[i]=x/p;
    v2[x%p]=1;
    w2[x/p]=1;
  }
  for(ll i=0;i<p;i++){
    if(v2[i]==0) v[p-1]=i;
    if(w2[i]==0) w[p-1]=i;
  }

  printf("? %lld %lld\n",1LL,p);
  cin>>x;
  x--;
  cout<<"! \n";
  if(x%p==v[0]){
    for(ll i=0;i<p;i++){
      for(ll j=0;j<p;j++){
        cout<<w[j]*p+v[i]+1<<" ";
      }
      cout<<"\n";
    }
  }else{
    for(ll i=0;i<p;i++){
      for(ll j=0;j<p;j++){
        cout<<w[i]*p+v[j]+1<<" ";
      }
      cout<<"\n";
    }
  }
}
0