結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー HaarHaar
提出日時 2021-06-11 21:38:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 1,986 ms
コンパイル使用メモリ 203,044 KB
実行使用メモリ 300,520 KB
最終ジャッジ日時 2023-08-21 11:49:50
合計ジャッジ時間 9,338 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 57 ms
90,620 KB
testcase_04 AC 95 ms
171,728 KB
testcase_05 AC 70 ms
109,400 KB
testcase_06 AC 104 ms
157,536 KB
testcase_07 AC 80 ms
131,892 KB
testcase_08 AC 63 ms
112,868 KB
testcase_09 AC 12 ms
15,748 KB
testcase_10 AC 100 ms
158,728 KB
testcase_11 AC 49 ms
76,228 KB
testcase_12 AC 45 ms
73,232 KB
testcase_13 AC 11 ms
12,888 KB
testcase_14 AC 123 ms
191,376 KB
testcase_15 AC 137 ms
192,636 KB
testcase_16 AC 42 ms
67,020 KB
testcase_17 AC 31 ms
47,428 KB
testcase_18 AC 10 ms
11,668 KB
testcase_19 AC 15 ms
20,780 KB
testcase_20 AC 121 ms
165,936 KB
testcase_21 AC 25 ms
35,556 KB
testcase_22 AC 13 ms
15,816 KB
testcase_23 AC 216 ms
262,044 KB
testcase_24 AC 217 ms
261,424 KB
testcase_25 AC 215 ms
261,052 KB
testcase_26 AC 211 ms
261,576 KB
testcase_27 AC 209 ms
261,328 KB
testcase_28 AC 211 ms
261,764 KB
testcase_29 AC 210 ms
263,012 KB
testcase_30 AC 212 ms
261,564 KB
testcase_31 AC 213 ms
262,700 KB
testcase_32 AC 214 ms
262,132 KB
testcase_33 AC 212 ms
261,944 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 211 ms
300,520 KB
testcase_39 AC 218 ms
261,580 KB
testcase_40 AC 215 ms
281,552 KB
testcase_41 AC 210 ms
261,248 KB
testcase_42 AC 205 ms
278,348 KB
testcase_43 AC 202 ms
288,252 KB
testcase_44 AC 206 ms
290,196 KB
testcase_45 AC 210 ms
279,288 KB
testcase_46 AC 202 ms
290,804 KB
testcase_47 AC 205 ms
275,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0