# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
599692 |
2022-07-19T18:57:14 Z |
stevancv |
Secret (JOI14_secret) |
C++14 |
|
443 ms |
4556 KB |
#include <bits/stdc++.h>
#include "secret.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 3e3 + 2;
struct block {
int m;
vector<int> a, b;
};
int a[N];
vector<block> all;
void Init(int n, int A[]) {
for (int i = 0; i < n; i++) a[i] = A[i];
function<void(int, int)> DQ = [&] (int l, int r) {
if (l >= r) return;
block tr;
int mid = l + r >> 1;
tr.m = mid;
tr.a.push_back(a[mid]);
for (int i = mid - 1; i >= l; i--) {
tr.a.push_back(Secret(a[i], tr.a.back()));
}
tr.b.push_back(a[mid + 1]);
for (int i = mid + 2; i <= r; i++) {
tr.b.push_back(Secret(tr.b.back(), a[i]));
}
all.push_back(tr);
DQ(l, mid - 1);
DQ(mid + 2, r);
};
DQ(0, n - 1);
}
int Query(int l, int r) {
if (l == r) return a[l];
for (auto xyz : all) {
int m = xyz.m;
vector<int> a = xyz.a;
vector<int> b = xyz.b;
if (l <= m && m <= r) {
int x = 0; if (m - l < a.size()) x = a[m - l];
int y = 0; if (r - m - 1 < b.size()) y = b[r - m - 1];
return Secret(x, y);
}
}
}
Compilation message
secret.cpp: In lambda function:
secret.cpp:22:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
22 | int mid = l + r >> 1;
| ~~^~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:45:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | int x = 0; if (m - l < a.size()) x = a[m - l];
| ~~~~~~^~~~~~~~~~
secret.cpp:46:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | int y = 0; if (r - m - 1 < b.size()) y = b[r - m - 1];
| ~~~~~~~~~~^~~~~~~~~~
secret.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
108 ms |
2308 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042. |
2 |
Incorrect |
110 ms |
2348 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 1257633. |
3 |
Incorrect |
108 ms |
2320 KB |
Wrong Answer: Query(128, 153) - expected : 959658850, actual : 473307172. |
4 |
Incorrect |
405 ms |
4320 KB |
Wrong Answer: Query(571, 624) - expected : 309502044, actual : 309493852. |
5 |
Incorrect |
423 ms |
4556 KB |
Wrong Answer: Query(626, 678) - expected : 512755800, actual : 160483352. |
6 |
Incorrect |
405 ms |
4300 KB |
Wrong Answer: Query(26, 30) - expected : 321366825, actual : 824419113. |
7 |
Correct |
430 ms |
4452 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
443 ms |
4512 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
424 ms |
4372 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
436 ms |
4416 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |