提交时间:2023-08-16 12:53:12
运行 ID: 98706
#include <iostream> #include <cstring> #include <cmath> #include <cstdio> #include <algorithm> using namespace std; typedef long long i64; const int SIZE = 2e5+5; int n, m; int a[SIZE], l[SIZE], r[SIZE], k[SIZE], ed; i64 tmp[SIZE << 1], cnt; namespace o1 { int main() { for (i64 o = 1; o <= m; ++o) { i64 cnt = 0; for (i64 i = l[o]; i <= r[o]; ++i) { if (a[i] == k[o]) ++cnt; a[i] = k[o]; } printf("%lld\n",cnt); } return 0; } } int main() { #ifdef fio freopen("test.in","r",stdin); #endif cin >> n >> m; for (i64 i = 1; i <= n; ++i) { scanf("%lld",&a[i]); tmp[++cnt] = a[i]; } for (i64 i = 1; i <= m; ++i) { scanf("%lld%lld%lld",l+i,r+i,k+i); tmp[++cnt] = k[i]; } sort(tmp + 1, tmp + 1 + cnt); ed = unique(tmp + 1, tmp + 1 + cnt) - tmp - 1; for (int i = 1; i <= n; ++i) { a[i] = lower_bound(tmp + 1, tmp + 1 + ed, a[i]) - tmp; } for (int i = 1; i <= m; ++i) { k[i] = lower_bound(tmp + 1, tmp + 1 + ed, k[i]) - tmp; } if (n <= 8000 && m <= 8000 && true) { return o1::main(); } else { puts("!"); } return 0; }