# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
52504 |
2018-06-26T06:15:24 Z |
tataky(#1353) |
비밀 (JOI14_secret) |
C++11 |
|
682 ms |
6580 KB |
#include "secret.h"
#include <map>
#include <utility>
using namespace std;
typedef pair<int, int> ip;
int sp[10][1001], to[10][1001], n;
int a[1001];
map<ip, int> d;
int Query(int L, int R) {
if (L == R) return a[L];
int len = R - L + 1;
int ret, cur = L;
bool fst = true;
for (int h = 9; h >= 0; h--) if (len&(1 << h)) {
if (fst) {
ret = sp[h][cur];
cur = to[h][cur] + 1;
fst = false;
}
else {
if (d.count(ip(ret, sp[h][cur]))) ret = d[ip(ret, sp[h][cur])];
else ret = d[ip(ret, sp[h][cur])] = Secret(ret, sp[h][cur]);
cur = to[h][cur] + 1;
}
}
return ret;
}
void setsparse() {
for (int i = 0; i < n; i++) {
sp[0][i] = a[i];
to[0][i] = i;
}
for (int h = 1; h <= 9; h++) {
for (int i = 0; i < n; i++) if (i + (1 << h) - 1< n) {
to[h][i] = to[h - 1][to[h - 1][i] + 1];
sp[h][i] = Secret(sp[h - 1][i], sp[h - 1][to[h - 1][i] + 1]);
}
}
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++)
a[i] = A[i];
setsparse();
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:16:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
int ret, cur = L;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
210 ms |
3796 KB |
Output is partially correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 7 |
2 |
Partially correct |
198 ms |
3972 KB |
Output is partially correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 7 |
3 |
Partially correct |
198 ms |
3972 KB |
Output is partially correct - number of calls to Secret by Init = 3604, maximum number of calls to Secret by Query = 7 |
4 |
Partially correct |
645 ms |
6404 KB |
Output is partially correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 8 |
5 |
Partially correct |
644 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8 |
6 |
Partially correct |
638 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 2 |
7 |
Partially correct |
682 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8 |
8 |
Partially correct |
631 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 6 |
9 |
Partially correct |
632 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8 |
10 |
Partially correct |
631 ms |
6580 KB |
Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 7 |