結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー Manuel1024
提出日時 2021-05-19 02:37:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 69,120 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-14 21:33:08
合計ジャッジ時間 3,903 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long int;

int main(){
    int n, m;
    cin >> n >> m;
    assert(1 <= n <= 5000);
    assert(1 <= m <= 5000);
    vector<int> a(n), b(m);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        assert(1 <= a[i] <= 10000);
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
        assert(1 <= b[i] <= 10000);
    }
    int ans = -1;
    for(int i = 0; i < n*m; i++){
        if(a[i%n] == b[i%m]){
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}
0