Submission #348461

# Submission time Handle Problem Language Result Execution time Memory
348461 2021-01-15T03:37:14 Z Kevin_Zhang_TW Intergalactic ship (IZhO19_xorsum) C++17
17 / 100
537 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

const int MAX_N = 1010, p = 1e9 + 7, MAX_Q = 100010;

int n, a[MAX_N], q, l[MAX_N], r[MAX_N], x[MAX_N];

ll pf[MAX_N], psq[MAX_N];

int brute_force() {

	ll res = 0;

	for (int s = 0;s < 1<<q;++s) {
		fill(pf, pf+n+1, 0);

		for (int i = 0;i < q;++i) if (s >> i & 1) 
			pf[ l[i] ] ^= x[i], pf[ r[i]+1 ] ^= x[i];

		for (int i = 1;i <= n;++i) 
			pf[i] ^= pf[i-1];

 		for (int i = 1;i <= n;++i) 
 			pf[i] = (pf[i] ^ a[i]) + pf[i-1];

 		for (int i = 1;i <= n;++i) {
			
			psq[i] = pf[i] * pf[i] % p;

			res = (res + psq[i] * n) % p;

			res = (res - 2ll * pf[i] * pf[i-1] % p + p) % p;

			pf[i] += pf[i-1];

		}
 
// 		res = (res + 1ll * pf[n] * pf[n]) % p;

	}

	return res;
}
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> n;

	for (int i = 1;i <= n;++i)
		cin >> a[i];

	cin >> q;

	for (int i = 0;i < q;++i)
		cin >> l[i] >> r[i] >> x[i];

	if (q > 20) return 1;

	cout << brute_force() << '\n';

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 537 ms 492 KB Output is correct
2 Correct 527 ms 492 KB Output is correct
3 Correct 527 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 537 ms 492 KB Output is correct
2 Correct 527 ms 492 KB Output is correct
3 Correct 527 ms 492 KB Output is correct
4 Incorrect 65 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 537 ms 492 KB Output is correct
10 Correct 527 ms 492 KB Output is correct
11 Correct 527 ms 492 KB Output is correct
12 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 537 ms 492 KB Output is correct
10 Correct 527 ms 492 KB Output is correct
11 Correct 527 ms 492 KB Output is correct
12 Incorrect 65 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Runtime error 1 ms 384 KB Execution failed because the return code was nonzero
10 Halted 0 ms 0 KB -