# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
677400 |
2023-01-03T07:50:58 Z |
jhwest2 |
None (JOI15_memory) |
C++17 |
|
1884 ms |
324700 KB |
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 100;
const int B = 1 << 22;
bool init = false;
array<int, 5> a[B];
map<array<int, 5>, int> mp;
void initialize(int n) {
int sz = 0;
for (int rev = 0; rev <= 1; rev++)
for (int s = 1; s <= n; s++)
for (int t = s; t <= n; t++)
for (int x = 0; x <= n / 2; x++)
for (int y = 0; y <= n / 2; y++)
if ((x + y) % 2 == (t - s) % 2 && x + y <= t - s)
a[sz++] = {rev, s, t, x, y};
for (int i = 0; i < sz; i++)
mp[a[i]] = i;
}
}
int Memory(int n, int m) {
if (!init) {
init = true;
initialize(n);
}
auto [rev, s, t, x, y] = a[m];
// assert(t != 0);
char c = Get(t);
if (!rev) {
if (s == t && (c == '>' || c == ')')) {
if (s != n) {
s = s + 1;
t = t + 1;
return mp[{rev, s, t, x, y}];
}
else {
rev = 1;
s = n;
t = n;
return mp[{rev, s, t, x, y}];
}
}
else {
if (c == '(')
++x;
if (c == ')')
--x;
if (c == '<')
++y;
if (c == '>')
--y;
if (x < 0 || y < 0 || x > n / 2 || y > n / 2)
return -2;
else {
if (x != 0 || y != 0) {
t = t + 1;
if (t == n + 1)
return -2;
else
return mp[{rev, s, t, x, y}];
}
else {
assert(s != n);
s = s + 1;
t = s;
x = 0;
y = 0;
return mp[{rev, s, t, x, y}];
}
}
}
}
else {
if (s == t && (c == '<' || c == '(')) {
if (s != 1) {
s = s - 1;
t = t - 1;
return mp[{rev, s, t, x, y}];
}
else
return -1;
}
else {
if (c == ')')
++x;
if (c == '(')
--x;
if (c == '>')
++y;
if (c == '<')
--y;
if (x < 0 || y < 0 || x > n / 2 || y > n / 2)
return -2;
else {
if (x != 0 || y != 0) {
t = t - 1;
if (t == 0)
return -2;
else
return mp[{rev, s, t, x, y}];
}
else {
assert(s != 1);
s = s - 1;
t = s;
x = 0;
y = 0;
return mp[{rev, s, t, x, y}];
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1884 ms |
324700 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |