結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
|
提出日時 | 2021-06-12 05:22:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 1,689 ms |
コンパイル使用メモリ | 166,720 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-15 16:29:18 |
合計ジャッジ時間 | 5,283 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
#include <iostream>#include <iomanip>#include <vector>#include <string>#include <set>#include <queue>#include <cmath>#include <algorithm>#include <bits/stdc++.h>using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define all(x) (x).begin(),(x).end()typedef long long ll;using P = pair<int,int>;#define INF 1001001001#define LINF (1LL<<60)#define F first#define S secondtemplate<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }int main() {int n, m; cin >> n >> m;vector<int> a(n);rep(i, n) cin >> a[i];vector<int> b(m);rep(i, m) cin >> b[i];int ans = -1;rep(i, n*m+1) {if (a[i%n] == b[i%m]) {ans = i+1;break;}}cout << ans << endl;}