제출 #530869

#제출 시각아이디문제언어결과실행 시간메모리
530869abc864197532Intergalactic ship (IZhO19_xorsum)C++17
0 / 100
1166 ms5448 KiB
#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 <vector <int>> cnt(n, vector <int> (32, 0)); for (int i = 0, x; i < n; ++i) cin >> x, cnt[i][x]++; cin >> q; for (int i = 0, l, r, x; i < q; ++i) { cin >> l >> r >> x, --l; assert(l + 1 == r); vector <int> ncnt = cnt[l]; for (int i = 0; i < 32; ++i) { cnt[l][i ^ x] += ncnt[i]; if (cnt[l][i ^ x] >= mod) cnt[l][i ^ x] -= mod; } } for (int i = 0; i < n; ++i) printv(all(cnt[i])); vector <vector <lli>> dp(n + 1, vector <lli>(3201, 0)); vector <lli> pre(161601, 0), dp2; dp[0][0] = 1; pre[0] = 1; lli ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < 3201; ++j) { for (int k = 0; k < 32; ++k) if (j + k < 3201) { (dp[i + 1][j + k] += dp[i][j] * cnt[i][k]) %= mod; } } dp2.assign(161601, 0); for (int j = 161600; ~j; --j) { for (int k = 31; ~k; --k) if (j + k * (n - i) < 161601) { (dp2[j + k * (n - i)] += pre[j] * cnt[i][k]) %= mod; } } pre = dp2; } for (int i = 1; i <= n; ++i) for (int j = 0; j < 3201; ++j) { (ans += dp[i][j] * j * j * (n + 1)) %= mod; } for (int j = 0; j < 161601; ++j) { (ans -= dp2[j] * j % mod * j) %= mod; } if (ans < 0) ans += mod; assert(0 <= ans && ans < mod); cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...