結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー forest3
提出日時 2021-06-20 01:44:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 167,496 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-22 22:22:43
合計ジャッジ時間 6,945 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A( N ), B( M );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	for( int i = 0; i < M; i++ ) {
		cin >> B[i];
	}

	int INF = INT32_MAX / 2;
	int ans = INF;
	for( int i = 0; i < N * M; i++ ) {
		if( A[i % N] == B[i % M] ) {
			ans = min( ans, i + 1 );
		}
	}
	if( ans == INF ) ans = -1;

	cout << ans << endl;
}
0