結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
24,012 KB
testcase_02 WA -
testcase_03 AC 25 ms
23,364 KB
testcase_04 WA -
testcase_05 AC 26 ms
24,372 KB
testcase_06 AC 25 ms
23,388 KB
testcase_07 AC 26 ms
24,072 KB
testcase_08 WA -
testcase_09 AC 26 ms
24,024 KB
testcase_10 AC 27 ms
23,628 KB
testcase_11 WA -
testcase_12 AC 26 ms
23,544 KB
testcase_13 AC 26 ms
24,012 KB
testcase_14 AC 28 ms
23,412 KB
testcase_15 AC 33 ms
23,628 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 96 ms
23,832 KB
testcase_21 AC 85 ms
23,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 92 ms
23,412 KB
testcase_25 AC 115 ms
23,676 KB
testcase_26 AC 117 ms
24,036 KB
testcase_27 AC 116 ms
23,412 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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 << ' ' << 1 << 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