結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
![]() |
提出日時 | 2024-06-06 15:13:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,397 ms / 2,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 2,134 ms |
コンパイル使用メモリ | 199,484 KB |
最終ジャッジ日時 | 2025-02-21 19:32:19 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/math>using namespace atcoder;void fast_io() {ios_base::sync_with_stdio(false);cin.tie(nullptr);}int main() {fast_io();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];}const int INF = 1e9;int ans = INF;for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (a[i] == b[j]) {auto [y, z] = crt({i, j}, {n, m});if (y == 0 && z == 0) continue;ans = min(ans, (int)y + 1);}}}cout << (ans == INF ? -1 : ans) << endl;}