結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
|
提出日時 | 2021-06-11 21:38:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 230 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 2,068 ms |
コンパイル使用メモリ | 196,416 KB |
最終ジャッジ日時 | 2025-01-22 05:37:14 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#include <bits/stdc++.h> #ifdef DEBUG #include <Mylib/Debug/debug.cpp> #else #define dump(...) #endif int main() { int N, M; std::cin >> N >> M; std::vector<int> A(N), B(M); for (int i = 0; i < N; ++i) std::cin >> A[i]; for (int i = 0; i < M; ++i) std::cin >> B[i]; std::vector<int> a, b; for (int i = 0; i < M; ++i) a.insert(a.end(), A.begin(), A.end()); for (int i = 0; i < N; ++i) b.insert(b.end(), B.begin(), B.end()); dump(a, b); int ans = INT_MAX; bool ok = false; for (int i = 0; i < N * M; ++i) { if (a[i] == b[i]) { ok = true; ans = std::min(ans, i + 1); } } if (ok) std::cout << ans << "\n"; else std::cout << -1 << "\n"; return 0; }