結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
![]() |
提出日時 | 2021-06-11 22:14:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 743 ms |
コンパイル使用メモリ | 80,240 KB |
最終ジャッジ日時 | 2025-01-22 06:02:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 WA * 6 RE * 7 |
ソースコード
#include <atcoder/math> #include <iostream> #include <stdio.h> #include <vector> #include <utility> #include <algorithm> using namespace std; using namespace atcoder; #define ll long long #define Pll pair<ll,ll> #define INF 1000000000000000000 signed main(){ ll N,M,K,ans=INF; cin>>N>>M; vector<ll> A(N); vector<ll> B(M); vector<ll>r(2); vector<ll>m={N,M}; for(ll i=0;i<N;i++)cin>>A.at(i); for(ll i=0;i<M;i++)cin>>B.at(i); for(ll i=0;i<N;i++)for(ll j=0;j<M;j++){ if(A.at(i)==B.at(j)){ r.at(0)=i+1; r.at(1)=j+1; Pll a=crt(r,m); ans=min(ans,a.first%a.second); } } if(ans==INF)printf("-1\n"); else printf("%lld\n",ans); return 0; }