結果
| 問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
| コンテスト | |
| ユーザー |
llawliet
|
| 提出日時 | 2021-06-11 21:33:29 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 535 bytes |
| 記録 | |
| コンパイル時間 | 982 ms |
| コンパイル使用メモリ | 180,840 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-25 14:12:02 |
| 合計ジャッジ時間 | 4,435 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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