結果
| 問題 |
No.1544 [Cherry 2nd Tune C] Synchroscope
|
| コンテスト | |
| ユーザー |
llawliet
|
| 提出日時 | 2021-06-11 21:33:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 535 bytes |
| コンパイル時間 | 1,968 ms |
| コンパイル使用メモリ | 167,720 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 22:33:03 |
| 合計ジャッジ時間 | 4,412 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 48 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
const int mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
for(int i=0; i<n; i++) cin >> a[i];
for(int j=0; j<m; j++) cin >> b[j];
int prod = (n * m) / (__gcd(n, m));
for(int i=0; i<prod; i++){
if(a[i%n] == b[i%m]){
cout << i+1 ;
return 0;
}
}
cout << -1 ;
return 0;
}
llawliet