QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#484626#4808. Great PartywyxqwqWA 1ms7780kbC++142.2kb2024-07-19 20:39:012024-07-19 20:39:02

Judging History

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

  • [2024-07-19 20:39:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7780kb
  • [2024-07-19 20:39:01]
  • 提交

answer

#include<bits/stdc++.h>
#define vectorwyx maze
namespace vectorwyx{
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define sml(x,y) (x=min(x,y))
#define big(x,y) (x=max(x,y))
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define umap unordered_map
#define db double
#define fo(i,x,y) for(int i=(x);i<=(y);++i)
#define go(i,x,y) for(int i=(x);i>=(y);--i)
#define ptc putchar
#define gtc getchar
#define emp emplace
#define re return
#define co continue
#define brk break
#define HH (ptc('\n'))
#define bctz __builtin_ctz
#define bclz __builtin_clz
#define bppc __builtin_popcount
using namespace std;
ll seed=chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
inline int rm(int x,int y){return (int)(rnd()%(y-x+1ll)+x);}
inline int read(){signed ch=getchar();int x=0,f=1;while(!isdigit(ch)){if(ch==(int)('-'))f=-1;ch=getchar();}while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
template<typename T> void out(T *a,int l,int r){fo(i,l,r) cout<<*(a+i)<<' ';puts("");}

const int N=1e5+5,V=1<<20|1;
int bel[N],a[N],n,m,cnt[2][V];
ll ans[N],Ans;
struct Ques{
    int l,r,od;
    Ques(){}
    Ques(int L,int R,int O){l=L,r=R,od=O;}
    bool operator<(const Ques&x)const{re bel[l]==bel[x.l]?r<x.r:bel[l]<bel[x.l];}
}q[N];

void add(int x){
    int &y=cnt[x&1][a[x]];
    Ans+=y;
    ++y;
}

void del(int x){
    int &y=cnt[x&1][a[x]];
    --y;
    Ans-=y;
}

signed main(){
    cin>>n>>m;
    fo(i,1,n) a[i]=read()^a[i-1];
    fo(i,1,m){
        int l=read(),r=read();
        ans[i]=(r-l)*(r-l+1ll)/2+(r-l+1);
        q[i]=Ques(l-1,r,i);
    }
    sort(q+1,q+1+m);
    int L=0,R=0;add(0);
    fo(i,1,m){
        while(R<q[i].r) add(++R);
        while(L>q[i].l) add(--L);
        while(R>q[i].r) del(R--);
        while(L<q[i].l) del(L++);
        ans[q[i].od]-=Ans;
    }
    fo(i,1,m) cout<<ans[i]<<'\n';
    return 0;
}
}
/*
4 5
1 2 2 4
1 2
2 3
3 4
1 3
2 4
-------------------------------------------------
*/










signed main(){re vectorwyx::main();}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

4 5
1 2 2 4
1 2
2 3
3 4
1 3
2 4

output:

3
2
3
5
5

result:

ok 5 number(s): "3 2 3 5 5"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

4 5
5 6 7 8
1 2
2 3
3 4
1 3
2 4

output:

3
3
3
6
6

result:

ok 5 number(s): "3 3 3 6 6"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

10 10
3 7 3 1 6 6 10 3 3 3
9 10
5 10
3 7
5 6
5 6
9 10
3 10
1 4
6 6
1 4

output:

2
18
14
2
2
2
33
10
1
10

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

10 8
91 63 1 34 50 11 10 73 96 67
5 9
2 7
2 5
4 7
1 10
3 3
1 4
5 10

output:

15
21
10
10
55
1
10
21

result:

ok 8 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

10 6
9 539 285 408 615 861 951 413 319 368
4 4
8 10
1 7
3 9
2 3
2 10

output:

1
6
28
28
3
45

result:

ok 6 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 7780kb

input:

10 6
1348 7002 4687 6325 8253 5750 2464 5509 6543 8704
3 9
4 8
8 8
8 9
2 9
9 10

output:

28
15
1
3
36
3

result:

ok 6 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

10 8
59041 28802 92255 14246 65768 79252 70656 81265 98363 85237
1 6
9 10
4 7
6 8
9 10
1 2
1 3
4 5

output:

21
3
10
6
3
3
6
3

result:

ok 8 numbers

Test #8:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

10 7
28607 249948 373828 584253 989446 308313 199311 253174 283937 133758
2 4
1 2
4 9
7 8
7 8
2 6
1 1

output:

6
3
21
3
3
15
1

result:

ok 7 numbers

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3776kb

input:

100 98
6 9 6 10 8 10 3 4 7 5 4 10 2 10 4 5 2 1 7 1 3 1 4 1 1 2 6 9 3 10 2 5 3 2 6 2 1 7 7 6 5 4 2 5 3 2 7 2 6 2 9 7 10 7 4 2 9 3 3 7 9 1 4 9 6 1 5 5 8 3 7 5 8 3 9 5 8 7 8 6 6 3 2 3 8 1 8 1 5 9 1 8 6 3 3 7 10 6 5 5
48 72
14 46
23 28
37 84
1 65
45 72
9 19
9 81
37 53
47 50
25 26
26 88
51 54
53 69
22 94...

output:

316
536
20
1144
2068
395
65
2611
148
10
3
1956
10
146
2611
33
167
6
27
316
604
2977
369
4596
2830
132
1226
53
164
2974
131
3059
798
1496
90
1946
225
65
76
423
335
646
266
1088
907
963
2682
2205
452
149
224
5
3783
1323
102
1229
576
2201
291
677
362
962
1
226
149
723
117
103
3370
911
132
1
90
1143
200...

result:

wrong answer 2nd numbers differ - expected: '534', found: '536'