結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー atjh16atjh16
提出日時 2021-09-23 17:17:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 164,140 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 19:54:41
合計ジャッジ時間 5,041 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 21 ms
4,380 KB
testcase_04 AC 41 ms
4,376 KB
testcase_05 AC 25 ms
4,380 KB
testcase_06 AC 32 ms
4,376 KB
testcase_07 AC 32 ms
4,380 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 31 ms
4,380 KB
testcase_11 AC 22 ms
4,376 KB
testcase_12 AC 18 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 44 ms
4,380 KB
testcase_15 AC 47 ms
4,376 KB
testcase_16 AC 17 ms
4,376 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 41 ms
4,376 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 63 ms
4,376 KB
testcase_24 AC 64 ms
4,376 KB
testcase_25 AC 63 ms
4,380 KB
testcase_26 AC 63 ms
4,380 KB
testcase_27 AC 63 ms
4,376 KB
testcase_28 AC 63 ms
4,380 KB
testcase_29 AC 63 ms
4,380 KB
testcase_30 AC 64 ms
4,376 KB
testcase_31 AC 64 ms
4,380 KB
testcase_32 AC 63 ms
4,376 KB
testcase_33 AC 79 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 79 ms
4,384 KB
testcase_39 AC 79 ms
4,380 KB
testcase_40 AC 79 ms
4,376 KB
testcase_41 AC 80 ms
4,376 KB
testcase_42 AC 77 ms
4,376 KB
testcase_43 AC 75 ms
4,376 KB
testcase_44 AC 76 ms
4,376 KB
testcase_45 AC 80 ms
4,380 KB
testcase_46 AC 76 ms
4,376 KB
testcase_47 AC 78 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n, m, w = 1e9;
int a[5000], b[5000];

int main()
{
	cin >> n >> m;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < m; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int u = (i + n * j) % m;

			if (a[i] == b[u]) {
				w = min(w, i + n * j + 1);
				break;
			}
		}
	}

	if (w == 1e9)
		cout << -1 << endl;
	else
		cout << w << endl;
}
0