Language: C++

#include<bits/stdc++.h>
using namespace std;
#define maxn 1e6
#define maxc 1001000
int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
struct query {
    int l, r, time, id;
} q[maxn];
struct modify {
    int pos, color, last;
} c[maxn];
int cntq, cntc, n, m, size, bnum;
int cmp(query a, query b) {
    return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.r] ^ belong[b.r]) ? belong[a.r] < belong[b.r] : a.time < b.time);
}
#define isdigit(x) ((x) >= '0' && (x) <= '9')
inline int read() {
    int res = 0;
    char c = getchar();
    while(!isdigit(c)) c = getchar();
    while(isdigit(c)) res = (res << 1) + (res << 3) + (c ^ 48), c = getchar();
    return res;
}
int main() {
    n = read();
    char s[maxn];
    scanf("%s",s+1);
	 m = read();
    size = pow(n, 2.0 / 3.0);
    bnum = ceil((double)n / size);
    for(int i = 1; i <= bnum; ++i) 
        for(int j = (i - 1) * size + 1; j <= i * size; ++j) belong[j] = i;
    for(int i = 1; i <= n; ++i) 
        a[i] =s[i]-'a';
    for(int i = 1; i <= m; ++i) {
        int opt;
        scanf("%d",&opt);
        if(opt==2) {
            q[++cntq].l = read();
            q[cntq].r = read();
            q[cntq].time = cntc;
            q[cntq].id = cntq;
        }
        else if(opt==1) {
            c[++cntc].pos = read();
            char cc[2];
            scanf("%s",cc);
            c[cntc].color =cc[0]-'a';
        }
    }
    sort(q + 1, q + cntq + 1, cmp);
    int l = 1, r = 0, time = 0, now = 0;
    for(int i = 1; i <= cntq; ++i) {
        int ql = q[i].l, qr = q[i].r, qt = q[i].time;
        while(l < ql) now -= !--cnt[a[l++]];
        while(l > ql) now += !cnt[a[--l]]++;
        while(r < qr) now += !cnt[a[++r]]++;
        while(r > qr) now -= !--cnt[a[r--]];
        while(time < qt) {
            ++time;
            if(ql <= c[time].pos && c[time].pos <= qr) now -= !--cnt[a[c[time].pos]] - !cnt[c[time].color]++;
            swap(a[c[time].pos], c[time].color);
        }
        while(time > qt) {
            if(ql <= c[time].pos && c[time].pos <= qr) now -= !--cnt[a[c[time].pos]] - !cnt[c[time].color]++;
            swap(a[c[time].pos], c[time].color);
            --time;
        }
        ans[q[i].id] = now;
    }
    for(int i = 1; i <= cntq; ++i) 
        printf("%d\n", ans[i]);
    return 0;
}


Compiler output:
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:7: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |       ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:5:7: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |       ^~~~
a.cc:3:14: error: size of array 'a' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:7: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |       ^~~~
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:29: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                             ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:5:29: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                             ^~~~
a.cc:3:14: error: size of array 'ans' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:29: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                             ^~~~
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:43: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                                           ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:5:43: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                                           ^~~~
a.cc:3:14: error: size of array 'belong' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:5:43: note: in expansion of macro 'maxn'
    5 | int a[maxn], cnt[maxc], ans[maxn], belong[maxn];
      |                                           ^~~~
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:8:5: note: in expansion of macro 'maxn'
    8 | } q[maxn];
      |     ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:8:5: note: in expansion of macro 'maxn'
    8 | } q[maxn];
      |     ^~~~
a.cc:3:14: error: size of array 'q' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:8:5: note: in expansion of macro 'maxn'
    8 | } q[maxn];
      |     ^~~~
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:11:5: note: in expansion of macro 'maxn'
   11 | } c[maxn];
      |     ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:11:5: note: in expansion of macro 'maxn'
   11 | } c[maxn];
      |     ^~~~
a.cc:3:14: error: size of array 'c' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:11:5: note: in expansion of macro 'maxn'
   11 | } c[maxn];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define maxn 1e6
      |              ^~~
a.cc:26:12: note: in expansion of macro 'maxn'
   26 |     char s[maxn];
      |            ^~~~
a.cc:3:14: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
    3 | #define maxn 1e6
      |              ^~~
      |              |
      |              double
a.cc:26:12: note: in expansion of macro 'maxn'
   26 |     char s[maxn];
      |            ^~~~
a.cc:3:14: error: size of array 's' has non-integral type 'double'
    3 | #define maxn 1e6
      |              ^~~
a.cc:26:12: note: in expansion of macro 'maxn'
   26 |     char s[maxn];
      |            ^~~~
a.cc:29:5: error: reference to 'size' is ambiguous
   29 |     size = pow(n, 2.0 / 3.0);
      |     ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:23: note:                 'int size'
   12 | int cntq, cntc, n, m, size, bnum;
      |                       ^~~~
a.cc:30:29: error: reference to 'size' is ambiguous
   30 |     bnum = ceil((double)n / size);
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:23: note:                 'int size'
   12 | int cntq, cntc, n, m, size, bnum;
      |                       ^~~~
a.cc:32:31: error: reference to 'size' is ambiguous
   32 |         for(int j = (i - 1) * size + 1; j <= i * size; ++j) belong[j] = i;
      |                               ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:23: note:                 'int size'
   12 | int cntq, cntc, n, m, size, bnum;
      |                       ^~~~
a.cc:32:50: error: reference to 'size' is ambiguous
   32 |         for(int j = (i - 1) * size + 1; j <= i * size; ++j) belong[j] = i;
      |                                                  ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:23: note:                 'int size'
   12 | int cntq, cntc, n, m, size, bnum;
      |                       ^~~~