QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55234#4808. Great PartyGZU_addd#WA 2ms3636kbC++2.3kb2022-10-12 19:56:582022-10-12 19:57:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 19:57:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3636kb
  • [2022-10-12 19:56:58]
  • 提交

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+10;
constexpr ll inf=1e18;
int n,m,a[N],len,col[M],res,w[N];
ll 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+1)*(r-l+1-res)/2;
    }
    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: 3556kb

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: 3636kb

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: -100
Wrong Answer
time: 2ms
memory: 3620kb

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
15
14
2
2
2
30
10
1
10

result:

wrong answer 2nd numbers differ - expected: '18', found: '15'