QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55229 | #4808. Great Party | GZU_addd# | WA | 2ms | 3804kb | C++ | 2.3kb | 2022-10-12 19:42:31 | 2022-10-12 19:42:34 |
Judging History
answer
#include<bits/stdc++.h>
#define ls u<<1
#define rs u<<1|1
#define fi first
#define se second
#define min amin
#define max amax
#define pb push_back
#define pq priority_queue
#define vt vector
#define lb(x) (x&-x)
#define sub(i,j) ((1LL*i-1LL*j)%k+k)%k
std::mt19937 rnd(233);
using namespace std;
using ll=long long;
//using node=pair<int,int>;
//using nnode=array<int,3>;
//inline int read(){
// int x=0,f=1;
// char c=getchar();
// while(c<'0'||c>'9'){
// if(c=='-') f=-1;
// c=getchar();
// }
// while(c>='0'&&c<='9'){
// x=x*10+(c^'0');
// c=getchar();
// }
// return x*f;
//}
template<typename T=int>T read(){T x;cin>>x;return x;}
template<typename U,typename V>auto min(U x,V y){return x<y?x:y;}
template<typename U,typename V>auto max(U x,V y){return x>y?x:y;}
template<typename U,typename...V>auto min(U x,V...y){return min(x,min(y...));}
template<typename U,typename...V>auto max(U x,V...y){return max(x,max(y...));}
template<typename U,typename V>bool cmin(U &x,V y){return x>y?x=y,true:false;}
template<typename U,typename V>bool cmax(U &x,V y){return x<y?x=y,true:false;}
constexpr int mod=998244353;
ll qpow(int x,int n=mod-2){ll y=1;for(;n;n>>=1,x=1LL*x*x%mod)if(n&1)y=1LL*y*x%mod;return y;}
//inline ll qpow(ll a, ll n=mod-2) { ll ans = 1; while (n) { if (n & 1) { ans *= a; }a *= a; n >>= 1; }return ans; }
constexpr int N=1e5+10,M=2e6;
constexpr ll inf=1e18;
ll n,m,a[N],len,col[M],res,w[N],ans[N];
struct node{int l,r,id;bool operator<(const node&W)const{int id1=l/len,id2=W.l/len;return id1^id2?id1<id2:r<W.r;}};
vt<node> pos;
void add(int x){if(col[x]++==0)++res;}
void del(int x){if(--col[x]==0)--res;}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;++i)cin>>a[i];
for(int i=1;i<=n;++i)w[i]=w[i-1]^a[i];
len=max(1,sqrt((double)n*n/m));
for(int l,r,i=1;i<=m;++i)cin>>l>>r,pos.pb({l-1,r,i});
sort(pos.begin(),pos.end());
int i=1,j=0;
for(auto [l,r,id]:pos){
while(j<r)add(w[++j]);
while(j>r)del(w[j--]);
while(i<l)del(w[i++]);
while(i>l)add(w[--i]);
ans[id]=1LL*(r-l+1)*(r-l)/2-1LL*(r-l+1-res);
}
for(int i=1;i<=m;++i)cout<<ans[i]<<"\n";
}
int main(){
cin.sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
// for(int T=read();T--;solve());
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3604kb
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: 2ms
memory: 3700kb
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: 2ms
memory: 3720kb
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: 3696kb
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: 2ms
memory: 3624kb
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: 2ms
memory: 3716kb
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: 2ms
memory: 3700kb
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: 2ms
memory: 3804kb
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: 2ms
memory: 3700kb
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:
313 538 19 1141 2095 391 63 2643 145 10 3 1967 10 147 2642 32 164 6 26 312 607 3018 363 4671 2864 131 1239 53 162 3017 129 3096 793 1499 87 1968 222 63 74 418 336 644 264 1094 916 959 2715 2225 447 146 222 5 3843 1339 99 1239 574 2226 287 679 363 960 1 221 146 717 115 99 3418 916 130 1 86 1141 198 1...
result:
wrong answer 1st numbers differ - expected: '316', found: '313'