結果
問題 | No.1863 Xor Sum 2...? |
ユーザー |
![]() |
提出日時 | 2022-03-04 22:18:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,439 bytes |
コンパイル時間 | 2,215 ms |
コンパイル使用メモリ | 203,912 KB |
最終ジャッジ日時 | 2025-01-28 05:30:14 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/modint>using namespace atcoder;//using mint = modint998244353;using mint = modint1000000007;using ll = long long;using ld = long double;using pll = pair<ll, ll>;using tlll = tuple<ll, ll, ll>;constexpr ll INF = 1LL << 60;template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}ll safemod(ll A, ll M) {return (A % M + M) % M;}ll divfloor(ll A, ll B) {if (B < 0) {return divfloor(-A, -B);} return (A - safemod(A, B)) / B;}ll divceil(ll A, ll B) {if (B < 0) {return divceil(-A, -B);} return divfloor(A + B - 1, B);}template<class T> void unique(vector<T> &V) {V.erase(unique(V.begin(), V.end()), V.end());}template<class T> void sortunique(vector<T> &V) {sort(V.begin(), V.end()); V.erase(unique(V.begin(), V.end()), V.end());}#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)template<class T> void printvec(vector<T> &V) {int _n = V.size(); for (int i = 0; i < _n; i++) cout << V[i] << (i == _n - 1 ? "" : " ");cout << '\n';}template<class T> void printvect(vector<T> &V) {for (auto v : V) cout << v << '\n';}template<class T> void printvec2(vector<vector<T>> &V) {for (auto &v : V) printvec(v);}int main(){ll N;cin >> N;vector<ll> A(N), B(N);for (ll i = 0; i < N; i++){cin >> A.at(i);}for (ll i = 0; i < N; i++){cin >> B.at(i);}vector<ll> S(N);S.at(0) = B.at(0);for (ll i = 0; i < N - 1; i++){S.at(i + 1) = S.at(i) ^ B.at(i + 1);}//printvec(S);const ll K = 32;vector<ll> cnt(K, 0);ll cnt0 = 0, cnt1 = 0;deque<ll> deq;ll ans = 0;for (ll i = 0; i < N; i++){deq.push_back(i);for (ll k = 0; k < K; k++){if (A.at(i) & (1LL << k))cnt.at(k)++;}while (*max_element(cnt.begin(), cnt.end()) >= 2){ll j = deq.front();deq.pop_front();for (ll k = 0; k < K; k++){if (A.at(j) & (1LL << k))cnt.at(k)--;}if (S.at(j) == 0)cnt0--;elsecnt1--;}ll tmp = (S.at(i) == 0 ? cnt0 : cnt1) + (B.at(i) == 0 ? 1 : 0);ans += tmp;//cerr << i << " " << deq.size() << " " << cnt0 << " " << cnt1 << " " << tmp << endl;if (S.at(i) == 0)cnt0++;elsecnt1++;}cout << ans << endl;}