結果

問題 No.2254 Reverse Only
ユーザー lddlinanlddlinan
提出日時 2023-03-24 23:10:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,207 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 92,920 KB
実行使用メモリ 10,628 KB
最終ジャッジ日時 2023-10-18 21:30:31
合計ジャッジ時間 7,124 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 235 ms
10,604 KB
testcase_09 WA -
testcase_10 AC 50 ms
4,684 KB
testcase_11 AC 239 ms
10,604 KB
testcase_12 AC 130 ms
10,612 KB
testcase_13 AC 232 ms
10,596 KB
testcase_14 AC 236 ms
10,620 KB
testcase_15 AC 227 ms
10,608 KB
testcase_16 AC 225 ms
10,612 KB
testcase_17 AC 224 ms
10,612 KB
testcase_18 AC 213 ms
10,628 KB
testcase_19 AC 74 ms
4,692 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 48 ms
4,684 KB
testcase_25 AC 50 ms
4,684 KB
testcase_26 AC 49 ms
4,684 KB
testcase_27 AC 6 ms
4,348 KB
testcase_28 AC 37 ms
5,268 KB
testcase_29 AC 92 ms
7,312 KB
testcase_30 AC 78 ms
6,860 KB
testcase_31 AC 40 ms
5,392 KB
testcase_32 AC 46 ms
5,668 KB
testcase_33 AC 20 ms
4,368 KB
testcase_34 AC 131 ms
8,252 KB
testcase_35 AC 75 ms
6,696 KB
testcase_36 AC 185 ms
9,804 KB
testcase_37 AC 203 ms
10,012 KB
testcase_38 AC 31 ms
4,944 KB
testcase_39 AC 183 ms
9,448 KB
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 67 ms
6,400 KB
testcase_42 AC 33 ms
5,100 KB
testcase_43 AC 134 ms
8,552 KB
testcase_44 AC 212 ms
10,304 KB
testcase_45 AC 126 ms
8,148 KB
testcase_46 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};



int as[200004];
int bs[200004];
int main() {
    int n, i, k, v;
    scanf("%d %d", &n, &k);
    for (i=0; i<n; i++) scanf("%d", &as[i]);
    for (i=0; i<n; i++) scanf("%d", &bs[i]);
    map<int, int> cs;
    for (i=0; i<n; i++) cs[as[i]]++;
    for (i=0; i<n; i++) {
        v=bs[i];
        if (cs[v]==0) break;
        cs[v]--;
    }
    if(i<n) printf("No\n");
    else {
        for (i=0; i<n; i++) if (as[i]!=bs[i]) break;
        if (i>=n) { printf("Yes\n"); return 0; }
        if (k>n) { printf("No\n"); return 0; }
        if (k==n) {
            for (i=0; i<n; i++) if (as[i]!=bs[n-1-i]) break;
            if (i>=n) printf("Yes\n");
            else printf("No\n");
            return 0;
        }
        printf("Yes\n");
    }
    return 0;
}
0