Submission #73429624


Source Code Expand

#include <bits/stdc++.h>
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")

using namespace std;
using ll = long long;
#define rep(i, n) for (ll i=0; i<n; i++)

const int bsize = 700;
int cnt[200000][300];
int a[200000];

int main() {
    ll n; cin >> n;
    rep(i, n) {cin >> a[i]; --a[i];}
    rep(i, n) rep(j, 300) cnt[i][j] = 0;
    rep(i, n) { cnt[a[i]][i / bsize]++; }
    ll q; cin >> q;
    rep(i, q) {
        ll l,r,x; cin >> l >> r >> x;
        --l; --x;
        ll ans = 0;
        while (l < r) {
            if (l % bsize == 0 && l+bsize <= r) {
                ans += cnt[x][l/bsize];
                l += bsize;
            } else {
                ans += (a[l] == x);
                l++;
            }
        }
        cout << ans << "\n";
    }
}

Submission Info

Submission Time
Task D - Range Count Query
User seekworser
Language C++23 (GCC 15.2.0)
Score 400
Code Size 845 Byte
Status AC
Exec Time 520 ms
Memory 238856 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 18
Set Name Test Cases
Sample 00_sample_01.txt
All 00_sample_01.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, 02_max_01.txt, 02_max_02.txt, 02_max_03.txt, 02_max_04.txt, 02_max_05.txt, 02_max_06.txt, 02_max_07.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3496 KiB
01_random_01.txt AC 178 ms 74800 KiB
01_random_02.txt AC 91 ms 49900 KiB
01_random_03.txt AC 180 ms 104580 KiB
01_random_04.txt AC 88 ms 148020 KiB
01_random_05.txt AC 284 ms 238388 KiB
01_random_06.txt AC 265 ms 110644 KiB
01_random_07.txt AC 167 ms 48284 KiB
01_random_08.txt AC 388 ms 140548 KiB
01_random_09.txt AC 349 ms 154520 KiB
01_random_10.txt AC 157 ms 126768 KiB
02_max_01.txt AC 467 ms 238792 KiB
02_max_02.txt AC 462 ms 238644 KiB
02_max_03.txt AC 462 ms 238856 KiB
02_max_04.txt AC 520 ms 238796 KiB
02_max_05.txt AC 516 ms 238772 KiB
02_max_06.txt AC 519 ms 238796 KiB
02_max_07.txt AC 493 ms 238728 KiB