結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー root__786root__786
提出日時 2021-06-11 22:50:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 200,812 KB
実行使用メモリ 462,808 KB
最終ジャッジ日時 2023-08-21 13:38:42
合計ジャッジ時間 44,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1,115 ms
433,720 KB
testcase_04 AC 754 ms
262,292 KB
testcase_05 AC 1,006 ms
424,704 KB
testcase_06 AC 967 ms
420,772 KB
testcase_07 AC 531 ms
227,164 KB
testcase_08 AC 1,011 ms
427,772 KB
testcase_09 AC 1,119 ms
448,596 KB
testcase_10 AC 1,032 ms
431,676 KB
testcase_11 AC 597 ms
239,768 KB
testcase_12 AC 432 ms
205,984 KB
testcase_13 AC 645 ms
252,828 KB
testcase_14 AC 1,169 ms
457,752 KB
testcase_15 AC 1,093 ms
443,732 KB
testcase_16 AC 518 ms
225,336 KB
testcase_17 AC 236 ms
110,656 KB
testcase_18 AC 173 ms
83,936 KB
testcase_19 AC 138 ms
77,452 KB
testcase_20 AC 904 ms
407,460 KB
testcase_21 AC 527 ms
226,752 KB
testcase_22 AC 306 ms
125,484 KB
testcase_23 AC 1,180 ms
462,116 KB
testcase_24 AC 1,187 ms
461,640 KB
testcase_25 AC 1,185 ms
461,908 KB
testcase_26 AC 1,190 ms
460,896 KB
testcase_27 AC 1,184 ms
461,508 KB
testcase_28 AC 1,180 ms
462,368 KB
testcase_29 AC 1,184 ms
461,728 KB
testcase_30 AC 1,184 ms
461,260 KB
testcase_31 AC 1,182 ms
461,224 KB
testcase_32 AC 1,183 ms
460,700 KB
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1,187 ms
461,612 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1,225 ms
462,808 KB
testcase_39 AC 1,233 ms
461,112 KB
testcase_40 AC 1,230 ms
460,980 KB
testcase_41 AC 1,241 ms
460,908 KB
testcase_42 AC 1,229 ms
459,476 KB
testcase_43 AC 1,189 ms
452,792 KB
testcase_44 AC 1,172 ms
454,188 KB
testcase_45 AC 1,197 ms
458,496 KB
testcase_46 AC 1,188 ms
458,016 KB
testcase_47 AC 1,192 ms
457,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int n,m;
    cin>>n>>m;
    int c=0;
    vector<int> a,b;
    int k;
    for(int i=0;i<n;i++){
        cin>>k;
        a.push_back(k);
    }
    for(int i=0;i<m;i++){
        cin>>k;
        b.push_back(k);
    }
    int same=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
        {
            if(a[i]==b[j]){
                same=1;
                break;
            }
        }
        if(same==1)
        break;
    }
    if(same==0){
        cout<<-1<<endl;
        return 0;
    }
    else{
        int size=max({m*n,m*m,n*n});
        size+=1;
        int i=0,c=0;
        vector<int> AA;
        while(i<n){
            if(c==size) break;
            AA.push_back(a[i]);
            i=(i+1)%n;
            c++;
        }
        vector<int> BB;
        int j=0;
        c=0;
        while(j<m){
            if(c==size) break;
            BB.push_back(b[j]);
            j=(j+1)%m;
            c++;
        }
        for(int i=0;i<AA.size();i++){
            if(AA[i]==BB[i]){
                cout<<(i+1);
                break;
            }
        }
    }
    return 0;
}
0