結果
| 問題 | 
                            No.1544 [Cherry 2nd Tune C] Synchroscope
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-12 01:02:23 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 146 ms / 2,000 ms | 
| コード長 | 657 bytes | 
| コンパイル時間 | 4,915 ms | 
| コンパイル使用メモリ | 273,356 KB | 
| 最終ジャッジ日時 | 2025-01-22 07:33:52 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 48 | 
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    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 id=-1;
    for(int i=0;i<n*m;i++){
        if(a[i%n]==b[i%m]){
            id=i+1;
            break;
        }
    }
    cout << id << endl;
}