Submission #56866430


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef long long ll;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
gp_hash_table<int, ll, chash> Table;

// ll Table[200'001];
const ll MOD = 999'999'999'989LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

unsigned int seed = 5;
unsigned int prand() {
    seed = seed * 214013 + 2531011;
    return (seed >> 16) & 0x7FF;
}

void create_table() {
    FOR(i,0,200'001) {
        Table[i] = ((ll)prand() | ((ll)prand() << 15) | ((ll)prand() << 30) | ((ll)prand() << 45));
    }
}

ll pSum1[200'001], pSum2[200'001];

ll mod(ll v) {
    return (v + MOD) % MOD;
}

int main() {
    create_table();
    int N, Q; scanf("%d %d", &N, &Q);

    FOR(i,1,N+1) {
        int cur; scanf("%d", &cur);
        pSum1[i] = (pSum1[i-1] + Table[cur]) % MOD;
    }
    FOR(i,1,N+1) {
        int cur; scanf("%d", &cur);
        pSum2[i] = (pSum2[i-1] + Table[cur]) % MOD;
    }
    FOR(q,0,Q) {
        int l1, r1, l2, r2; scanf("%d %d %d %d", &l1, &r1, &l2, &r2);
        if (r1 - l1 == r2 - l2 && mod(pSum1[r1] - pSum1[l1-1]) == mod(pSum2[r2] - pSum2[l2-1])) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Submission Info

Submission Time
Task F - Rearrange Query
User readiz
Language C++ 17 (gcc 12.2)
Score 500
Code Size 1435 Byte
Status AC
Exec Time 141 ms
Memory 24908 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:38:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |     int N, Q; scanf("%d %d", &N, &Q);
      |               ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:41:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |         int cur; scanf("%d", &cur);
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:45:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         int cur; scanf("%d", &cur);
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:49:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |         int l1, r1, l2, r2; scanf("%d %d %d %d", &l1, &r1, &l2, &r2);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 60
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt, 01_random_56.txt, 01_random_57.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 16 ms 21580 KiB
00_sample_01.txt AC 16 ms 21744 KiB
01_random_00.txt AC 29 ms 21648 KiB
01_random_01.txt AC 47 ms 21508 KiB
01_random_02.txt AC 39 ms 21736 KiB
01_random_03.txt AC 46 ms 21652 KiB
01_random_04.txt AC 41 ms 21624 KiB
01_random_05.txt AC 46 ms 21580 KiB
01_random_06.txt AC 46 ms 21640 KiB
01_random_07.txt AC 48 ms 21648 KiB
01_random_08.txt AC 118 ms 24780 KiB
01_random_09.txt AC 120 ms 24824 KiB
01_random_10.txt AC 118 ms 24788 KiB
01_random_11.txt AC 120 ms 24828 KiB
01_random_12.txt AC 120 ms 24788 KiB
01_random_13.txt AC 121 ms 24908 KiB
01_random_14.txt AC 122 ms 24676 KiB
01_random_15.txt AC 114 ms 24908 KiB
01_random_16.txt AC 115 ms 24816 KiB
01_random_17.txt AC 118 ms 24816 KiB
01_random_18.txt AC 115 ms 24908 KiB
01_random_19.txt AC 115 ms 24752 KiB
01_random_20.txt AC 113 ms 24796 KiB
01_random_21.txt AC 112 ms 24812 KiB
01_random_22.txt AC 115 ms 24748 KiB
01_random_23.txt AC 118 ms 24752 KiB
01_random_24.txt AC 114 ms 24672 KiB
01_random_25.txt AC 115 ms 24748 KiB
01_random_26.txt AC 137 ms 24904 KiB
01_random_27.txt AC 137 ms 24788 KiB
01_random_28.txt AC 135 ms 24856 KiB
01_random_29.txt AC 136 ms 24848 KiB
01_random_30.txt AC 138 ms 24796 KiB
01_random_31.txt AC 133 ms 24816 KiB
01_random_32.txt AC 138 ms 24828 KiB
01_random_33.txt AC 139 ms 24808 KiB
01_random_34.txt AC 134 ms 24808 KiB
01_random_35.txt AC 138 ms 24744 KiB
01_random_36.txt AC 134 ms 24788 KiB
01_random_37.txt AC 135 ms 24792 KiB
01_random_38.txt AC 135 ms 24904 KiB
01_random_39.txt AC 137 ms 24824 KiB
01_random_40.txt AC 134 ms 24824 KiB
01_random_41.txt AC 138 ms 24812 KiB
01_random_42.txt AC 136 ms 24748 KiB
01_random_43.txt AC 134 ms 24808 KiB
01_random_44.txt AC 141 ms 24816 KiB
01_random_45.txt AC 137 ms 24824 KiB
01_random_46.txt AC 16 ms 21684 KiB
01_random_47.txt AC 16 ms 21732 KiB
01_random_48.txt AC 116 ms 24800 KiB
01_random_49.txt AC 112 ms 24832 KiB
01_random_50.txt AC 110 ms 24800 KiB
01_random_51.txt AC 110 ms 24816 KiB
01_random_52.txt AC 121 ms 24820 KiB
01_random_53.txt AC 121 ms 24780 KiB
01_random_54.txt AC 126 ms 24748 KiB
01_random_55.txt AC 125 ms 24804 KiB
01_random_56.txt AC 124 ms 24904 KiB
01_random_57.txt AC 44 ms 21580 KiB