結果

問題 No.2496 LCM between Permutations
ユーザー planesplanes
提出日時 2023-11-13 01:46:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 175,144 KB
実行使用メモリ 24,012 KB
平均クエリ数 952.90
最終ジャッジ日時 2023-11-13 01:46:32
合計ジャッジ時間 6,665 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,012 KB
testcase_01 AC 24 ms
24,012 KB
testcase_02 AC 25 ms
24,012 KB
testcase_03 AC 24 ms
24,012 KB
testcase_04 WA -
testcase_05 AC 26 ms
24,012 KB
testcase_06 AC 25 ms
24,012 KB
testcase_07 AC 26 ms
24,012 KB
testcase_08 AC 29 ms
24,012 KB
testcase_09 WA -
testcase_10 AC 26 ms
24,012 KB
testcase_11 AC 26 ms
24,012 KB
testcase_12 AC 26 ms
24,012 KB
testcase_13 AC 26 ms
24,012 KB
testcase_14 AC 25 ms
24,012 KB
testcase_15 AC 32 ms
24,012 KB
testcase_16 AC 34 ms
24,012 KB
testcase_17 AC 34 ms
24,012 KB
testcase_18 AC 95 ms
24,012 KB
testcase_19 AC 71 ms
24,012 KB
testcase_20 AC 96 ms
24,012 KB
testcase_21 AC 90 ms
24,012 KB
testcase_22 AC 79 ms
24,012 KB
testcase_23 AC 103 ms
24,012 KB
testcase_24 AC 91 ms
24,012 KB
testcase_25 AC 114 ms
24,012 KB
testcase_26 AC 115 ms
24,000 KB
testcase_27 AC 115 ms
24,000 KB
testcase_28 AC 115 ms
24,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:91:19: warning: 'one' may be used uninitialized [-Wmaybe-uninitialized]
   91 |   cout<<"? "<<one+1<<" "<<i+1<<endl;
      |                   ^
main.cpp:84:4: note: 'one' was declared here
   84 | ll one;
      |    ^~~

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll N;cin>>N;
  if(N==1) {
    cout<<"! "<<1<<" "<<1<<endl;
    return 0;
  }

  vector<bool> note(N+1);
  
  for(ll i=2;i<=N;i++) {
    if(note[i]) continue;
    for(ll j=2;j*i<=N;j++) note[j*i]=true;
  }


vector<ll> A(N),B(N);

vector<ll> C(N);
for(ll i=0;i<N;i++) {
  cout<<"? "<<1<<" "<<i+1<<endl;
  ll X;cin>>X;
  C[i]=X;
}

ll mi=INF;
for(ll i=0;i<N;i++) mi=min(mi,C[i]);
A[0]=mi;
ll ma=0,ind=0;

for(ll i=0;i<N;i++) {
  ll k=C[i]/A[0];
  if(!note[k]&&ma<k) {
    ma=k;
    ind=i;
  }
}

B[ind]=ma;

vector<ll> D(N);
for(ll i=1;i<N;i++) {
  cout<<"? "<<i+1<<" "<<ind+1<<endl;
  ll X;cin>>X;
  D[i]=X;
}

for(ll i=1;i<N;i++) {
  A[i]=D[i]/ma;
}

vector<ll> vec(0);
for(ll i=0;i<N;i++) {
if(A[i]==1) vec.push_back(i);
}


ll to=0;
if(ind==0) to=1;
cout<<"? "<<vec[0]+1<<" "<<to+1<<endl;
ll X;cin>>X;
if(X%ma==0) {
  A[vec[0]]=ma;
  A[vec[1]]=1;
}
else {
  A[vec[0]]=1;
  A[vec[1]]=ma;
}


ll one;
for(ll i=0;i<N;i++) {
  if(A[i]==1) one=i;
}

for(ll i=0;i<N;i++) {
  if(i==ind) continue;
  cout<<"? "<<one+1<<" "<<i+1<<endl;
  ll X;cin>>X;
  B[i]=X;
}


cout<<"! ";
for(auto x:A) cout<<x<<" ";
for(auto x:B) cout<<x<<" ";
cout<<endl;
}






0