이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false)
#endif
const int mod = 1e9 + 7, N = 200000;
int main () {
owo;
int n, q;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
cin >> q;
vector <array <int, 3>> updates(q);
for (int i = 0; i < q; ++i) {
cin >> updates[i][0] >> updates[i][1] >> updates[i][2];
--updates[i][0];
}
lli ans = 0;
for (int s = 0; s < 1 << q; ++s) {
vector <int> b = a;
for (int i = 0; i < q; ++i) if (s >> i & 1) {
for (int j = updates[i][0]; j < updates[i][1]; ++j)
b[j] ^= updates[i][2];
}
for (int i = 1; i < n; ++i)
(b[i] += b[i - 1]) %= mod;
lli pre_sq = 0, pre_sum = 0;
for (int i = 0; i < n; ++i) {
(pre_sq += b[i] * b[i]) %= mod;
(pre_sum += b[i]) %= mod;
}
(ans += pre_sq * (n + 1) + mod - pre_sum * pre_sum % mod) %= mod;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |