結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
![]() |
提出日時 | 2021-06-11 21:24:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 154 ms / 2,000 ms |
コード長 | 1,179 bytes |
コンパイル時間 | 1,833 ms |
コンパイル使用メモリ | 195,416 KB |
最終ジャッジ日時 | 2025-01-22 05:27:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#include <bits/stdc++.h>using namespace std;struct iofast_t {iofast_t() {ios::sync_with_stdio(false);cin.tie(nullptr);}} iofast;struct uns_t {} uns;template <typename Element, typename Head, typename ...Args>auto vec(Element init, Head arg, Args ...args) {if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);else return std::vector(arg, vec(init, args...));}template <typename Element, typename Head, typename ...Args>auto vec(uns_t, Head arg, Args ...args) {return vec(Element(), arg, args...);}template <typename T, typename Compare = less<T>>T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }template <typename T, typename Compare = less<T>>T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }int main() {int n, m; cin >> n >> m;auto a = vec<int>(uns, n);auto b = vec<int>(uns, m);for (auto &e : a) cin >> e;for (auto &e : b) cin >> e;int l = lcm(n, m);for (int i = 0; i < l; ++i) {if (a[i % n] == b[i % m]) {cout << i + 1 << endl;return 0;}}cout << -1 << endl;}