Submission #257290

#TimeUsernameProblemLanguageResultExecution timeMemory
257290BTheroIntergalactic ship (IZhO19_xorsum)C++17
12 / 100
2088 ms512 KiB
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = (int)1e3 + 5; const int MOD = (int)1e9 + 7; array<int, 3> que[MAXN]; int dp[128][128], ndp[128][128]; int arr[MAXN]; int n, q, ans; int addMod(int a, int b, int m = MOD) { a += b; if (m <= a) { a -= m; } return a; } int mulMod(int a, int b, int m = MOD) { return a * 1ll * b % m; } bool bit(int x, int p) { return x & (1 << p); } void solve() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &arr[i]); } scanf("%d", &q); for (int i = 1; i <= q; ++i) { int l, r, x; scanf("%d %d %d", &l, &r, &x); que[i] = {l, r, x}; } for (int a = 1; a <= n; ++a) { for (int b = 1; b <= n; ++b) { for (int x = 0; x < 128; ++x) { for (int y = 0; y < 128; ++y) { dp[x][y] = ndp[x][y] = 0; } } dp[arr[a]][arr[b]] = 1; for (int i = 1; i <= q; ++i) { auto &[l, r, k] = que[i]; for (int x = 0; x < 128; ++x) { for (int y = 0; y < 128; ++y) { ndp[x][y] = addMod(ndp[x][y], dp[x][y]); int nx = x, ny = y; if (l <= a && a <= r) { nx ^= k; } if (l <= b && b <= r) { ny ^= k; } ndp[nx][ny] = addMod(ndp[nx][ny], dp[x][y]); } } for (int x = 0; x < 128; ++x) { for (int y = 0; y < 128; ++y) { dp[x][y] = ndp[x][y]; ndp[x][y] = 0; } } } for (int x = 0; x < 128; ++x) { for (int y = 0; y < 128; ++y) { int cur = mulMod(min(a, b), n - max(a, b) + 1); cur = mulMod(cur, mulMod(x, y)); cur = mulMod(cur, dp[x][y]); ans = addMod(ans, cur); } } } } printf("%d\n", ans); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'void solve()':
xorsum.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
xorsum.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &arr[i]);
     ~~~~~^~~~~~~~~~~~~~~
xorsum.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
xorsum.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &l, &r, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...