# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1019696 |
2024-07-11T07:38:12 Z |
codefox |
Secret (JOI14_secret) |
C++14 |
|
306 ms |
4560 KB |
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
vector<vector<int>> rright;
vector<vector<int>> lleft;
/*
int Secret(int a, int b)
{
cout << a << " " << b << endl;
int x;
cin >> x;
return x;
}
*/
void initialize(int l, int r, int A[])
{
if (l==r) return;
if (l==r+1) return;
if (l== r+2) return;
int m = (l+r)/2;
for (int i = m+1; i < r; i++)
{
rright[m].push_back(Secret(rright[m].back(), A[i]));
}
for (int i = m-2; i >= l; i--)
{
lleft[m-1].push_back(Secret(lleft[m-1].back(), A[i]));
}
initialize(l, m-1, A);
initialize(m+1, r, A);
}
void Init(int N, int A[]) {
rright.assign(N, vector<int>());
lleft.assign(N, vector<int>());
for (int i = 0; i < N; i++)
{
rright[i].push_back(A[i]);
lleft[i].push_back(A[i]);
}
initialize(0, N, A);
}
int Query(int L, int R) {
int ss = R-L+1;
if (rright[L].size()>=ss)
{
return rright[L][ss-1];
}
if (lleft[R].size()>=ss)
{
return lleft[R][ss-1];
}
for (int i = L+1; i <= R; i++)
{
if (rright[i].size()>= R-i+1 && lleft[i-1].size()>= i-L)
{
return Secret(rright[i][R-i], lleft[i-1][i-1-L]);
}
}
return 0;
}
/*
int main()
{
int n, q;
cin >> n;
int A[n];
for (int i = 0; i < n; i++)
{
cin >> A[i];
}
cin >> q;
Init(n, A);
for (int i = 0; i < q; i++)
{
int a, b;
cin >> a >> b;
cout << Query(a, b) << "\n";
}
}
*/
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:51:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | if (rright[L].size()>=ss)
| ~~~~~~~~~~~~~~~~^~~~
secret.cpp:55:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
55 | if (lleft[R].size()>=ss)
| ~~~~~~~~~~~~~~~^~~~
secret.cpp:61:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
61 | if (rright[i].size()>= R-i+1 && lleft[i-1].size()>= i-L)
| ~~~~~~~~~~~~~~~~^~~~~~~~
secret.cpp:61:58: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
61 | if (rright[i].size()>= R-i+1 && lleft[i-1].size()>= i-L)
| ~~~~~~~~~~~~~~~~~^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
2388 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 34607541. |
2 |
Incorrect |
77 ms |
2424 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 755105792. |
3 |
Incorrect |
76 ms |
2388 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 362156408. |
4 |
Incorrect |
300 ms |
4432 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 108544080. |
5 |
Incorrect |
299 ms |
4432 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 659085336. |
6 |
Incorrect |
303 ms |
4432 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 850129153. |
7 |
Incorrect |
296 ms |
4436 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 773554242. |
8 |
Incorrect |
304 ms |
4560 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 490922392. |
9 |
Incorrect |
306 ms |
4440 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 939919433. |
10 |
Incorrect |
303 ms |
4436 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 274803083. |