結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 182 ms
78,336 KB
testcase_04 AC 400 ms
126,672 KB
testcase_05 AC 273 ms
107,140 KB
testcase_06 AC 344 ms
116,552 KB
testcase_07 AC 336 ms
113,708 KB
testcase_08 AC 211 ms
82,568 KB
testcase_09 AC 28 ms
12,348 KB
testcase_10 AC 330 ms
114,320 KB
testcase_11 AC 193 ms
79,876 KB
testcase_12 AC 170 ms
75,384 KB
testcase_13 AC 32 ms
13,116 KB
testcase_14 AC 434 ms
130,596 KB
testcase_15 AC 553 ms
208,792 KB
testcase_16 AC 165 ms
75,172 KB
testcase_17 AC 96 ms
41,432 KB
testcase_18 AC 26 ms
13,000 KB
testcase_19 AC 44 ms
22,236 KB
testcase_20 AC 416 ms
130,660 KB
testcase_21 AC 88 ms
40,744 KB
testcase_22 AC 33 ms
14,216 KB
testcase_23 AC 717 ms
233,368 KB
testcase_24 AC 716 ms
234,236 KB
testcase_25 AC 709 ms
234,700 KB
testcase_26 AC 705 ms
233,028 KB
testcase_27 AC 705 ms
233,560 KB
testcase_28 AC 707 ms
233,860 KB
testcase_29 AC 707 ms
233,356 KB
testcase_30 AC 706 ms
233,884 KB
testcase_31 AC 709 ms
233,184 KB
testcase_32 AC 705 ms
235,024 KB
testcase_33 WA -
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 735 ms
233,872 KB
testcase_39 AC 741 ms
233,632 KB
testcase_40 AC 735 ms
234,172 KB
testcase_41 AC 734 ms
232,892 KB
testcase_42 AC 723 ms
232,552 KB
testcase_43 AC 690 ms
229,048 KB
testcase_44 AC 696 ms
228,956 KB
testcase_45 AC 716 ms
231,824 KB
testcase_46 AC 698 ms
229,012 KB
testcase_47 AC 709 ms
232,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int 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=(m*n)+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