結果

問題 No.2496 LCM between Permutations
ユーザー achapiachapi
提出日時 2023-10-06 23:21:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 200,692 KB
実行使用メモリ 24,492 KB
平均クエリ数 953.97
最終ジャッジ日時 2023-10-06 23:21:34
合計ジャッジ時間 7,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 24 ms
23,412 KB
testcase_02 AC 24 ms
24,264 KB
testcase_03 AC 25 ms
23,664 KB
testcase_04 AC 26 ms
24,048 KB
testcase_05 AC 25 ms
23,544 KB
testcase_06 WA -
testcase_07 AC 26 ms
24,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 27 ms
23,388 KB
testcase_15 AC 32 ms
23,364 KB
testcase_16 AC 34 ms
23,232 KB
testcase_17 WA -
testcase_18 AC 94 ms
24,240 KB
testcase_19 WA -
testcase_20 AC 96 ms
24,336 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 113 ms
23,832 KB
testcase_26 AC 118 ms
24,468 KB
testcase_27 WA -
testcase_28 AC 115 ms
23,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> _A(N);
	int g = 0;
	for (int i = 0; i < N; i++){
		cout << "? " << i + 1 << ' ' << N << endl;
		int X;
		cin >> X;
		g = gcd(g, X);
		_A[i] = X;
	}
	int a = -1;
	for (int i = 0; i < N; i++){
		_A[i] /= g;
		if (_A[i] == 1){
			a = i + 1;
		}
	}
	vector<int> A(N), B(N);
	int b = -1;
	for (int i = 0; i < N; i++){
		cout << "? " << a << ' ' << i + 1 << endl;
		int X;
		cin >> X;
		B[i] = X;
		if (X == 1){
			b = i + 1;
		}
	}
	for (int i = 0; i < N; i++){
		cout << "? " << i + 1 << ' ' << b << endl;
		int X;
		cin >> X;
		A[i] = X;
	}
	cout << "! ";
	for (int i = 0; i < N; i++){
		cout << A[i];
		cout << ' ';
	}
	for (int i = 0; i < N; i++){
		cout << B[i];
		if (i + 1 < N){
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
}
0