답안 #950721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950721 2024-03-20T15:45:50 Z willychan Intergalactic ship (IZhO19_xorsum) C++17
100 / 100
1431 ms 7700 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
const int MOD = 1e9+7;
const int N = 1e5+5;
int p2[N];

inline int mul(const int &a,const int &b){
	return (1LL*a*b)%MOD;
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin>>a[i];
	int q;cin>>q;
	vector<tuple<int,int,int> > Q(q);
	for(int i=0;i<q;i++){
		cin>>get<0>(Q[i])>>get<1>(Q[i])>>get<2>(Q[i]);
	}
	p2[0]=1;
	for(int i=1;i<=max(q,100);i++) p2[i] = (2LL*p2[i-1])%MOD;
	ll ans = 0;
	for(int b1=0;b1<7;b1++){for(int b2=0;b2<7;b2++){
		vector<int> cnt1(n+2,0);
		vector<int> cnt2(n+2,0);
		vector<vector<int> > both(n+2,vector<int>(n+2,0));
		for(auto &[l,r,x] : Q){
			if((x>>b1)&1) cnt1[l]++,cnt1[r+1]--;
			if((x>>b2)&1) cnt2[l]++,cnt2[r+1]--;
			if(((x>>b1)&1) & ((x>>b2)&1)){
				both[l][l]++;both[l][r+1]--;
				both[r+1][l]--;both[r+1][r+1]++;
			}
		}
		for(int i=1;i<=n;i++){
			cnt1[i]+=cnt1[i-1];
			cnt2[i]+=cnt2[i-1];
		}
		for(int i=0;i<=n;i++) {
			for(int j=1;j<=n;j++) both[i][j]+=both[i][j-1];
		}
		for(int j=0;j<=n;j++){
			for(int i=1;i<=n;i++) both[i][j]+=both[i-1][j];
		}
		for(int l=1;l<=n;l++){
			for(int r=1;r<=n;r++){
				int bO = (both[l][r]==0)?(0):(p2[both[l][r]-1]);
				int bE =  (both[l][r]==0)?(1):(p2[both[l][r]-1]);
				int o1 = (cnt1[l]-both[l][r]==0)?(0):(p2[cnt1[l]-both[l][r]-1]);
				int e1 = (cnt1[l]-both[l][r]==0)?(1):(p2[cnt1[l]-both[l][r]-1]);
				int o2 = (cnt2[r]-both[l][r]==0)?(0):(p2[cnt2[r]-both[l][r]-1]);
				int e2 = (cnt2[r]-both[l][r]==0)?(1):(p2[cnt2[r]-both[l][r]-1]);
				if((a[l]>>b1)&1) swap(o1,e1);
				if((a[r]>>b2)&1) swap(o2,e2);
				ll v = (mul(bO,mul(e1,e2))+mul(bE,mul(o1,o2)))%MOD;
				v = (v*p2[q-cnt1[l]-cnt2[r]+both[l][r]])%MOD;
				v = mul(v,mul(min(l,r),(n-max(l,r)+1)));
				v = mul(v,p2[b1+b2]);
				ans = (ans+v)%MOD;
			}
		}
	}}
	cout<<ans<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 13 ms 504 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 2736 KB Output is correct
2 Correct 19 ms 728 KB Output is correct
3 Correct 13 ms 348 KB Output is correct
4 Correct 12 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1282 ms 4656 KB Output is correct
2 Correct 1258 ms 4740 KB Output is correct
3 Correct 1270 ms 4676 KB Output is correct
4 Correct 1228 ms 5012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 13 ms 504 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 13 ms 348 KB Output is correct
13 Correct 13 ms 348 KB Output is correct
14 Correct 13 ms 512 KB Output is correct
15 Correct 13 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 13 ms 504 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 13 ms 348 KB Output is correct
17 Correct 13 ms 348 KB Output is correct
18 Correct 13 ms 512 KB Output is correct
19 Correct 13 ms 348 KB Output is correct
20 Correct 395 ms 4092 KB Output is correct
21 Correct 390 ms 4116 KB Output is correct
22 Correct 357 ms 3984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 13 ms 504 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 66 ms 2736 KB Output is correct
10 Correct 19 ms 728 KB Output is correct
11 Correct 13 ms 348 KB Output is correct
12 Correct 12 ms 344 KB Output is correct
13 Correct 1282 ms 4656 KB Output is correct
14 Correct 1258 ms 4740 KB Output is correct
15 Correct 1270 ms 4676 KB Output is correct
16 Correct 1228 ms 5012 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 4 ms 348 KB Output is correct
24 Correct 13 ms 348 KB Output is correct
25 Correct 13 ms 348 KB Output is correct
26 Correct 13 ms 512 KB Output is correct
27 Correct 13 ms 348 KB Output is correct
28 Correct 395 ms 4092 KB Output is correct
29 Correct 390 ms 4116 KB Output is correct
30 Correct 357 ms 3984 KB Output is correct
31 Correct 1376 ms 7064 KB Output is correct
32 Correct 1353 ms 7700 KB Output is correct
33 Correct 1322 ms 7172 KB Output is correct
34 Correct 1431 ms 7016 KB Output is correct
35 Correct 1376 ms 7496 KB Output is correct
36 Correct 1386 ms 7508 KB Output is correct