結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー oooooba
提出日時 2021-08-02 20:59:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 115,236 KB
最終ジャッジ日時 2025-01-23 13:44:20
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n, m;
    cin >> n >> m;
    vector<int32_t> as(n), bs(m);
    for (auto &&a : as) {
        cin >> a;
    }
    for (auto &&b : bs) {
        cin >> b;
    }
    int32_t ans = -1;
    for (auto i = 0; i < n * m; ++i) {
        if (as[i % n] == bs[i % m]) {
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}
0