結果

問題 No.1863 Xor Sum 2...?
ユーザー 沙耶花沙耶花
提出日時 2022-03-04 21:56:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,158 bytes
コンパイル時間 4,534 ms
コンパイル使用メモリ 262,596 KB
実行使用メモリ 6,116 KB
最終ジャッジ日時 2023-09-26 00:51:57
合計ジャッジ時間 8,880 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 27 ms
4,376 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 44 ms
4,380 KB
testcase_08 AC 43 ms
4,380 KB
testcase_09 AC 114 ms
5,736 KB
testcase_10 AC 104 ms
5,744 KB
testcase_11 AC 59 ms
4,400 KB
testcase_12 AC 41 ms
4,376 KB
testcase_13 AC 83 ms
4,704 KB
testcase_14 AC 104 ms
5,816 KB
testcase_15 AC 81 ms
4,668 KB
testcase_16 AC 85 ms
4,672 KB
testcase_17 AC 47 ms
4,376 KB
testcase_18 AC 21 ms
4,376 KB
testcase_19 AC 39 ms
4,380 KB
testcase_20 AC 66 ms
4,424 KB
testcase_21 AC 96 ms
5,660 KB
testcase_22 AC 34 ms
4,376 KB
testcase_23 AC 123 ms
5,808 KB
testcase_24 AC 134 ms
5,968 KB
testcase_25 AC 138 ms
6,004 KB
testcase_26 AC 140 ms
6,116 KB
testcase_27 AC 138 ms
5,992 KB
testcase_28 AC 138 ms
5,984 KB
testcase_29 AC 139 ms
6,056 KB
testcase_30 AC 138 ms
6,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000000000000

using P = pair<int,int>;
P op(P a,P b){
	a.first &= b.first;
	a.second ^= b.second;
	return a;
}

P e(){
	return make_pair((1<<30)-1,0);
}	

long long cnt[2];
int main(){
	
	int n;
	cin>>n;
	vector<P> t(n);
	rep(i,n){
		cin>>t[i].first;
	}
	rep(i,n){
		cin>>t[i].second;
	}
	segtree<P,op,e> seg(t);
	vector<int> cc(30,0);
	long long ans = 0LL;
	int r = 0;
	int rr = 0;
	rep(i,n){
		while(true){
			if(r==n)break;
			int m = 0;
			rep(j,30){
				if((t[r].first>>j)&1){
					cc[j]++;
					m = max(m,cc[j]);
				}
			}
			if(m<=1){
				r++;
			}
			else{
				rep(j,30){
					if((t[r].first>>j)&1){
						cc[j]--;
						m = max(m,cc[j]);
					}
				}
				break;
			}
		}
		
		while(r!=rr){
			rr++;
			cnt[seg.prod(0,rr).second]++;
			//rr++;
		}
		//cout<<r<<','<<cnt[0]<<','<<cnt[1]<<endl;
		ans += cnt[seg.prod(0,i).second];
		cnt[seg.prod(0,i+1).second]--;
		rep(j,30){
			if((t[i].first>>j)&1)cc[j]--;
		}
		
	}
	cout<<ans<<endl;
	
	return 0;
}
0