結果

問題 No.2496 LCM between Permutations
ユーザー umimel
提出日時 2023-10-06 23:23:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,594 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 178,320 KB
実行使用メモリ 28,488 KB
平均クエリ数 953.97
最終ジャッジ日時 2024-07-26 17:06:03
合計ジャッジ時間 7,774 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60;
const int IINF = (1 << 30) - 1;
template<typename T> struct Edge{
int to; T w;
Edge(int to_, T w_=1){
to = to_;
w=w_;
}
};
template<typename T> using Tree = vector<vector<Edge<T>>>;
template<typename T> using Graph = vector<vector<Edge<T>>>;
/* & for Dinic */
template<typename T> struct REdge{
int to;
T cap;
T cost;
int rev;
REdge(int to_, T cap_, T cost_=1){
to = to_;
cap = cap_;
cost = cost_;
}
REdge(int to_, T cap_, T cost_, int rev_){
to = to_;
cap = cap_;
cost = cost_;
rev = rev_;
}
};
/* for Dinic */
template<typename T> using RGraph = vector<vector<REdge<T>>>;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n; cin >> n;
vector<vector<ll>> P(n, vector<ll>(n, 0));
for(ll i=0; i<n; i++){
for(ll j=0; j<n; j++){
P[i][j] = (i+1)/__gcd(i+1, j+1)*(j+1);
}
sort(all(P[i]));
}
//1
vector<ll> Q;
for(ll j=1; j<=n; j++){
cout << "? " << 1 << " " << j << endl;
ll tmp; cin >> tmp;
Q.pb(tmp);
}
vector<ll> SQ = Q;
sort(all(SQ));
ll X = 0;
for(ll i=0; i<n; i++){
bool ok = true;
for(ll j=0; j<n; j++) if(SQ[j]!=P[i][j]) ok = false;
if(ok){
X = i;
break;
}
}
X++;
ll B1 = 0;
for(ll j=0; j<n; j++) if(Q[j]==X){
B1 = j+1;
break;
}
//2
vector<ll> A;
for(ll i=1; i<=n; i++){
cout << "? " << i << " " << B1 << endl;
ll tmp; cin >> tmp;
A.pb(tmp);
}
ll A1 = 0;
rep(i, n){
if(A[i]==1){
A1 = i+1;
break;
}
}
//3
vector<ll> B;
for(ll j=1; j<=n; j++){
cout << "? " << A1 << " " << j << endl;
ll tmp; cin >> tmp;
B.pb(tmp);
}
cout << "! ";
rep(i, n) cout << A[i] << " ";
rep(i, n) cout << B[i] << " ";
cout << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0