Submission #344215

#TimeUsernameProblemLanguageResultExecution timeMemory
344215NurlykhanIntergalactic ship (IZhO19_xorsum)C++17
0 / 100
182 ms1568 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 10; const int M = 256; const int mod = (int)1e9 + 7; int n, q; int a[N], b[N]; int l[N], r[N], x[N]; int t[N]; int dp[M + M], old_dp[M + M]; int get_sum(int id) { memset(old_dp, 0, sizeof(old_dp)); old_dp[a[id]] = 1; for (int i = 0; i < q; i++) { if (l[i] <= id && id <= r[i]) { memset(dp, 0, sizeof(dp)); for (int j = 0; j < M; j++) { (dp[j ^ x[i]] += old_dp[j]) %= mod; } for (int j = 0; j < M; j++) { (old_dp[j] += dp[j]) %= mod; } } } int ans = 0; for (int i = 0; i < M; i++) { (ans += i * 1ll * old_dp[i] % mod) %= mod; } return ans; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); scanf("%d", &q); for (int i = 0; i < q; i++) scanf("%d%d%d", &l[i], &r[i], &x[i]); int ans = 0; for (int i = 1; i <= n; i++) { t[i] = get_sum(i); //cout << i << ' ' << get_sum(i) << endl; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { //cout << i << ' ' << j << ' ' << get_sum(i) * 1ll * get_sum(j) * min(i, j) * min(n - i + 1, n - j + 1) (ans += t[i] * 1ll * t[j] * min(i, j) * min(n - i + 1, n - j + 1) % mod) %= mod; } } cout << ans; return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
xorsum.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
xorsum.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
xorsum.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |         scanf("%d%d%d", &l[i], &r[i], &x[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...