QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507571#8672. 排队LVJBot10 774ms40132kbC++142.4kb2024-08-06 19:24:192024-08-06 19:24:19

Judging History

你现在查看的是最新测评结果

  • [2024-08-06 19:24:19]
  • 评测
  • 测评结果:0
  • 用时:774ms
  • 内存:40132kb
  • [2024-08-06 19:24:19]
  • 提交

answer

/* Submission UUID: 21346. */
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_TEST
bool __mem_begin;
#endif
mt19937_64 __rnd;
#define rand() __rnd()
#define int long long
#define mid ((l+r)>>1)
#ifndef LOCAL_TEST
#define endl '\n'
#endif
#ifdef SEGMENT_TREE
#define lson (p<<1)
#define rson (p<<1|1)
#endif
#ifdef NETWORK_FLOW
#define rev(p) (p^1)
#endif
const int MAXN=2e5+5,MAXV=1e6+5;int n,m,a[MAXN],anss[MAXN],cnt[MAXV],B,ans;struct _stck{vector<int>lst;int tp=0;_stck(){lst.resize(2);}void pop(){tp--;}void push(int x){tp++;if (tp>=lst.size()) lst.push_back(x);else lst[tp]=x;}int top(){return lst[tp];}}st[MAXN];struct _node{int type,l,r,t,L,R;bool operator<(const _node b) const{if (L !=b.L) return L<b.L;if (R !=b.R) return R<b.R;return (R&1 ? t<b.t : t>b.t);}}qrs[MAXN],qrs2[MAXN];void add(int x){if (cnt[a[x]]==0)++ans;cnt[a[x]]++;}void del(int x){cnt[a[x]]--;if (cnt[a[x]]==0)--ans;}void work(){cin>>n>>m;B=pow(n,2.0/3.0);for (int i=1;i<=n;++i){cin>>a[i];st[i].push(a[i]);}for (int i=1;i<=m;++i){char opt;int l,r;cin>>opt>>l>>r;qrs[i].type=(opt=='R');qrs[i].l=l;qrs[i].r=r;qrs[i].t=i;qrs[i].L=l/B;qrs[i].R=r/B;qrs2[i]=qrs[i];}sort(qrs+1,qrs+1+m);int l=1,r=0,t=0;for (int i=1;i<=m;++i){if (qrs[i].type==1) continue;while (t<qrs[i].t){t++;if (qrs2[t].type==0) continue;if (l<=qrs2[t].l&&qrs2[t].l<=r) del(qrs2[t].l);a[qrs2[t].l]=qrs2[t].r;st[qrs2[t].l].push(qrs2[t].r);if (l<=qrs2[t].l&&qrs2[t].l<=r) add(qrs2[t].l);}while (t>qrs[i].t){t--;if (qrs2[t].type==0) continue;if (l<=qrs2[t].l&&qrs2[t].l<=r) del(qrs2[t].l);st[qrs2[t].l].pop();a[qrs2[t].l]=st[qrs2[t].l].top();if (l<=qrs2[t].l&&qrs2[t].l<=r) add(qrs2[t].l);}while (l>qrs[i].l) add(--l);while (r<qrs[i].r) add(++r);while (l<qrs[i].l) del(l++);while (r>qrs[i].r) del(r--);anss[qrs[i].t]=ans;}for (int i=1;i<=m;++i){if (qrs2[i].type==1) continue;cout<<anss[i]<<endl;}}
#ifdef LOCAL_TEST
bool __mem_end;
#endif
signed main(void){ios::sync_with_stdio(false);cin.tie(NULL);srand(time(nullptr));__rnd=mt19937_64(chrono::steady_clock::now().time_since_epoch().count());
#ifdef LOCAL_TEST
auto __time_begin=clock();
#endif
#ifdef FILE_IO
#ifndef LOCAL_TEST
freopen(".in","r",stdin);freopen(".out","w",stdout);
#endif
#endif
#ifdef MULTI_TESTS
int ___T=1;cin>>___T;___T--;while (___T--) work();
#endif
work();
#ifdef LOCAL_TEST
auto __time_end=clock();cerr<<"Time: "<<__time_end-__time_begin<<"ms"<<endl;cerr<<"Memory: "<<(&__mem_end-&__mem_begin)/1024<<"KiB"<<endl;
#endif
return 0;}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 24508kb

input:

3 3
0 0
1 2
0 2
1 1
1 3
2 3

output:

1
1
2

result:

wrong answer 2nd numbers differ - expected: '3', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 150ms
memory: 39964kb

input:

200000 200000
3 6
3 3
6 10
1 7
2 7
6 9
4 6
3 4
0 8
0 6
3 5
3 4
1 8
7 8
4 5
0 3
1 5
2 9
1 2
1 2
3 4
5 7
6 10
3 9
4 7
1 6
2 6
1 7
2 5
1 7
6 8
1 1
0 7
7 8
0 9
1 7
3 8
3 7
1 2
4 8
5 6
0 6
5 6
2 7
2 6
0 6
0 6
1 7
2 5
0 3
0 3
7 10
3 8
0 2
3 4
3 7
4 9
0 6
4 7
2 6
8 10
2 10
4 10
3 3
2 6
4 5
3 9
1 8
1 2
2 9
...

output:

0
3
0
2
2
3
4
0
6
0
3
0
3
0
4
5
3
2
2
3
4
4
0
4
0
4
1
1
0
5
2
3
4
0
5
0
2
0
3
0
3
0
1
0
7
0
1
0
6
2
6
0
4
1
2
3
0
2
2
3
0
3
0
3
0
2
0
3
0
2
0
3
0
3
0
2
0
2
0
3
0
6
0
2
0
2
0
3
0
6
2
3
3
0
3
0
2
0
1
6
0
5
0
2
3
5
2
1
0
4
0
4
7
0
3
0
3
0
4
0
6
0
4
0
3
0
3
1
3
0
3
3
0
2
1
2
2
0
2
0
6
0
3
0
1
0
3
0
7
2
...

result:

wrong answer 1st numbers differ - expected: '11', found: '0'

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 774ms
memory: 40132kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:

0
0
33339
0
0
33340
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
33352
0
0
33353
0
0
0
33354
0
0
0
0
1
1
33357
1
33358
0
0
0
0
0
1
0
0
33361
0
0
1
1
0
1
1
33365
1
33367
1
0
33369
1
0
0
33371
1
0
0
1
0
0
0
33373
0
0
0
33375
0
0
33375
0
33376
0
0
0
0
0
1
1
33378
0
1
0
33379
0
33380
0
33381
0
0
0
3338...

result:

wrong answer 1st numbers differ - expected: '19141', found: '0'

Subtask #4:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 510ms
memory: 39872kb

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:

0
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
2
1
1
2
1
1
1
1
1
1
2
1
2
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
...

result:

wrong answer 1st numbers differ - expected: '71224', found: '0'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%