# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1030481 |
2024-07-22T05:39:52 Z |
KienTran |
Secret (JOI14_secret) |
C++14 |
|
301 ms |
4436 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int O = 2e3 + 5;
//const int N = (1 << 20) + 5;
const int mod = 1e9 + 7; //998244353;
const int inf = 1e18;
int pr[] = {167772161, 469762049, 754974721, 1045430273, 1051721729, 1053818881};
const double eps = 1e-10;
int n, a[O], mask[O], f[21][O];
/*int Secret(int x, int y){
return x + y;
}*/
void DnC(int l, int r, int level){
if (level > 8) return;
int mid = (l + r) / 2;
DnC(l, mid, level + 1);
DnC(mid + 1, r, level + 1);
f[level][mid] = a[mid];
for (int i = mid - 1; i >= l; -- i) f[level][i] = Secret(f[level][i + 1], a[i]);
f[level][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; ++ i) f[level][i] = Secret(f[level][i - 1], a[i]);
for (int i = mid + 1; i <= r; ++ i) mask[i] |= (1 << level);
}
void Init(int N, int A[]){
for (int i = 0; i < N; ++ i){
a[i] = A[i];
mask[i] = 0;
}
DnC(0, N - 1, 0);
}
int Query(int L, int R){
if (L == R) return a[L];
if (L + 1 == R){
return Secret(a[L], a[R]);
}
int x, cur = mask[L] ^ mask[R];
for (int i = 0; i < 10; ++ i){
if (cur >> i & 1){
x = i;
break;
}
}
return Secret(f[x][L], f[x][R]);
}
/*main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; ++ i){
cin >> a[i];
}
Init(n, a);
int q; cin >> q;
while (q --){
int l, r; cin >> l >> r;
cout << Query(l, r) << endl;
}
}*/
/**
**/
Compilation message
secret.cpp:9:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
9 | const int inf = 1e18;
| ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:56:18: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
56 | return Secret(f[x][L], f[x][R]);
| ~~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
2384 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
71 ms |
2384 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
79 ms |
2520 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
286 ms |
4332 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
291 ms |
4436 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
266 ms |
4364 KB |
Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445. |
7 |
Incorrect |
301 ms |
4436 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
273 ms |
4436 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
284 ms |
4436 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
278 ms |
4432 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |