結果

問題 No.1306 Exactly 2 Digits
ユーザー 👑 NachiaNachia
提出日時 2020-12-03 22:10:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,109 bytes
コンパイル時間 2,069 ms
コンパイル使用メモリ 201,392 KB
実行使用メモリ 24,516 KB
平均クエリ数 1320.26
最終ジャッジ日時 2023-09-24 08:40:46
合計ジャッジ時間 26,937 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
23,580 KB
testcase_02 AC 25 ms
24,060 KB
testcase_03 AC 25 ms
23,388 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 29 ms
23,448 KB
testcase_10 AC 28 ms
23,424 KB
testcase_11 AC 28 ms
24,348 KB
testcase_12 WA -
testcase_13 AC 28 ms
24,360 KB
testcase_14 AC 29 ms
24,348 KB
testcase_15 AC 29 ms
23,868 KB
testcase_16 WA -
testcase_17 AC 27 ms
24,336 KB
testcase_18 WA -
testcase_19 AC 27 ms
23,568 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
24,060 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 28 ms
23,712 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 27 ms
23,400 KB
testcase_29 AC 27 ms
24,348 KB
testcase_30 WA -
testcase_31 AC 26 ms
24,012 KB
testcase_32 AC 27 ms
23,988 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 28 ms
23,652 KB
testcase_36 WA -
testcase_37 AC 27 ms
23,448 KB
testcase_38 AC 27 ms
24,012 KB
testcase_39 AC 28 ms
23,448 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 27 ms
23,556 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 29 ms
23,688 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 34 ms
24,372 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 36 ms
23,436 KB
testcase_55 WA -
testcase_56 AC 41 ms
23,448 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 42 ms
24,336 KB
testcase_60 WA -
testcase_61 AC 55 ms
23,436 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 65 ms
23,424 KB
testcase_69 AC 69 ms
23,880 KB
testcase_70 AC 69 ms
23,436 KB
testcase_71 WA -
testcase_72 AC 71 ms
23,424 KB
testcase_73 AC 73 ms
24,264 KB
testcase_74 WA -
testcase_75 AC 78 ms
23,388 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 113 ms
24,096 KB
testcase_81 AC 93 ms
23,436 KB
testcase_82 AC 118 ms
24,336 KB
testcase_83 AC 118 ms
24,288 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 AC 110 ms
24,312 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 AC 119 ms
23,460 KB
testcase_90 AC 105 ms
23,988 KB
testcase_91 WA -
testcase_92 AC 103 ms
24,048 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 110 ms
24,012 KB
testcase_96 AC 102 ms
23,988 KB
testcase_97 WA -
testcase_98 WA -
testcase_99 AC 112 ms
23,532 KB
testcase_100 WA -
testcase_101 WA -
testcase_102 AC 104 ms
24,336 KB
testcase_103 AC 110 ms
24,084 KB
testcase_104 WA -
testcase_105 AC 109 ms
23,448 KB
testcase_106 AC 99 ms
23,400 KB
testcase_107 AC 113 ms
23,556 KB
testcase_108 AC 103 ms
24,096 KB
testcase_109 WA -
testcase_110 WA -
testcase_111 WA -
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 AC 135 ms
24,336 KB
testcase_117 AC 119 ms
23,640 KB
testcase_118 WA -
testcase_119 AC 108 ms
23,664 KB
testcase_120 WA -
testcase_121 WA -
testcase_122 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0;i<(n);i++)

int N;

struct Node{
  int p,q;
  int val()const{return p*N+q;}
  Node operator+(Node r)const{return {p+r.p,q+r.q};}
  Node operator-(Node r)const{return {p-r.p,q-r.q};}
  bool operator<(Node r)const{return val()<r.val();}
  bool operator==(Node r)const{return p==r.p && q==r.q;}
};

Node f(Node l,Node r){ Node x={l.p-r.p,l.q-r.q}; if(x.p>x.q) swap(x.p,x.q); return x; }

const int sign_offset=100;

int main(){
  cin>>N;
  int NN=N*N-N;
  Node R[2500]; R[0]={0,0};
  for(int i=2; i<=NN; i++){ cout<<"? "<<i<<" "<<1<<endl; cin>>R[i-1].p>>R[i-1].q; }
  int C[sign_offset*2]={}; rep(i,NN){ C[R[i].p+sign_offset]++; C[R[i].q+sign_offset]++; }

  Node ans1={-1,-1};

  rep(i,sign_offset*2-1){
    if(C[i]+N <= C[i+1]){ ans1.p = -(i-sign_offset); for(int j=i+1; j<=i+N-1; j++) C[i]-=N; }
    if(C[i]+N-1 <= C[i+1]){ ans1.q = -(i-sign_offset)-1; for(int j=i+1; j<=i+N-1; j++) C[i]-=(N-1); }
  }

  Node corner_val= {1,N-1};
  if(ans1.q > N-1-ans1.q) corner_val={N-1,0};
  int corner_p = -1;
  rep(i,NN) if(f(corner_val,ans1)==R[i]) corner_p=i;

  Node ans[2500]; rep(i,NN) ans[i]={-1,-1};
  Node min_box = Node{1,0}-ans1;
  Node max_box = Node{N-1,N-1}-ans1;

    rep(i,NN){
      if(ans[i].p!=-1) continue;
      if(R[i].p==R[i].q){ ans[i]=ans1+R[i]; continue; }
      if(R[i].p<min_box.p || R[i].q<min_box.q || R[i].p>max_box.p || R[i].q>max_box.q){
        swap(R[i].p,R[i].q);
        ans[i]=R[i]+ans1;
        continue;
      }
      if(R[i].q<min_box.p || R[i].p<min_box.q || R[i].q>max_box.p || R[i].p>max_box.q){
        ans[i]=R[i]+ans1;
        continue;
      }

      int rev=i+1; for(; rev<NN; rev++) if(R[i]==R[rev]) break;
      cout<<"? "<<(i+1)<<" "<<(corner_p+1)<<endl;
      Node res; cin>>res.p>>res.q; if(corner_val.q!=0) swap(res.p,res.q);
      ans[i]=res+corner_val;
      Node revres = ans[i]-ans1; swap(revres.p,revres.q); revres=revres+ans1;
      ans[rev]=revres;
    }

  cout<<"!";
  rep(i,NN) cout<<" "<<ans[i].val();
  cout<<endl;

  return 0;
}
0