#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 1000
#define MQ 100000
#define mod 1000000007
lli n,pot,act,a,q,res;
lli arr[MAX+2], l[MQ+2], r[MQ+2], k[MQ+2];
lli acu1[MAX+2],acu2[MAX+2],acu3[MAX+2],dp[MAX+2];
lli cambio[MAX+2],nuevo[MAX+2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
rep(i,1,n) cin >> arr[i];
cin >> q;
rep(i,1,q) cin >> l[i] >> r[i] >> k[i];
res = 0;
pot = 1<<q;
act = 0;
while (act < pot) {
rep(i,1,n) cambio[i] = 0;
rep(i,1,q) {
a = 1<<(i-1);
if (a&act) {
cambio[ l[i] ] ^= k[i];
cambio[ r[i]+1 ] ^= k[i];
}
}
a = 0;
rep(i,1,n) {
a ^= cambio[i];
nuevo[i] = arr[i]^a;
acu1[i] = acu1[i-1] + i*nuevo[i];
acu2[i] = acu2[i-1] + i*nuevo[i]*nuevo[i];
acu3[i] = acu3[i-1] + 2*nuevo[i]*acu1[i-1];
dp[i] = dp[i-1] + acu2[i] + acu3[i];
}
res += dp[n];
res %= mod;
act++;
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
3440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2055 ms |
328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
348 KB |
Output is correct |
2 |
Correct |
196 ms |
348 KB |
Output is correct |
3 |
Correct |
183 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
348 KB |
Output is correct |
2 |
Correct |
196 ms |
348 KB |
Output is correct |
3 |
Correct |
183 ms |
344 KB |
Output is correct |
4 |
Incorrect |
4 ms |
472 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
187 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
344 KB |
Output is correct |
12 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
187 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
344 KB |
Output is correct |
12 |
Incorrect |
4 ms |
472 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
16 ms |
3440 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |