# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
595782 |
2022-07-14T06:37:48 Z |
maomao90 |
None (JOI15_memory) |
C++17 |
|
2906 ms |
284256 KB |
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)
template <class T>
bool inline mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
bool inline mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}
typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int MAXN = 100;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;
inline bool isop(char c) {
return c == '[' || c == '<';
}
inline int getno(char c) {
if (c == '[' || c == ']') {
return 1;
} else {
return 2;
}
}
inline vi itov(int m) {
vi res(4, 0);
res[0] = m % MAXN;
m /= MAXN;
res[1] = m % MAXN;
m /= MAXN;
res[2] = m % MAXN;
m /= MAXN;
res[3] = m;
return res;
}
inline int vtoi(vi v) {
int res = 0;
RREP (i, 3, 0) {
res *= MAXN;
res += v[i];
}
return res;
}
int Memory(int n, int m) {
vi cur = itov(m);
if (cur[0] >= n || cur[1] >= n || cur[2] >= n || cur[3] >= 3) {
return -2;
}
char c = Get(cur[1] + 1);
cerr << cur[0] << ' ' << cur[1] << ' ' << cur[2] << ' ' << cur[3] << ' ' << c << '\n';
if (cur[2] == cur[0] && isop(c)) {
if (cur[3] != 0) {
return -2;
}
cur[3] = getno(c);
} else if (cur[2] - 1 == cur[0] && !isop(c)) {
if (cur[3] != getno(c)) {
return -2;
}
cur[3] = 0;
}
cur[2] += isop(c) ? 1 : -1;
if (cur[2] < 0) {
return -2;
}
if (cur[1] < n - 1) {
cur[1]++;
} else {
if (cur[2] != 0) {
return -2;
}
if (cur[0] == n - 1) {
return -1;
}
cur[0]++;
cur[1] = 0;
cur[2] = 0;
cur[3] = 0;
}
assert(cur[0] <= n - 1);
cerr << cur[0] << ' ' << cur[1] << ' ' << cur[2] << ' ' << cur[3] << '\n';
cerr << vtoi(cur) << '\n';
return vtoi(cur);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2596 ms |
284256 KB |
Output is correct |
2 |
Correct |
2632 ms |
283988 KB |
Output is correct |
3 |
Correct |
2574 ms |
284040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2596 ms |
284256 KB |
Output is correct |
2 |
Correct |
2632 ms |
283988 KB |
Output is correct |
3 |
Correct |
2574 ms |
284040 KB |
Output is correct |
4 |
Correct |
2602 ms |
284016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2596 ms |
284256 KB |
Output is correct |
2 |
Correct |
2632 ms |
283988 KB |
Output is correct |
3 |
Correct |
2574 ms |
284040 KB |
Output is correct |
4 |
Correct |
2602 ms |
284016 KB |
Output is correct |
5 |
Correct |
2538 ms |
283980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2596 ms |
284256 KB |
Output is correct |
2 |
Correct |
2632 ms |
283988 KB |
Output is correct |
3 |
Correct |
2574 ms |
284040 KB |
Output is correct |
4 |
Correct |
2602 ms |
284016 KB |
Output is correct |
5 |
Correct |
2538 ms |
283980 KB |
Output is correct |
6 |
Correct |
2517 ms |
284100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2906 ms |
284008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2596 ms |
284256 KB |
Output is correct |
2 |
Correct |
2632 ms |
283988 KB |
Output is correct |
3 |
Correct |
2574 ms |
284040 KB |
Output is correct |
4 |
Correct |
2602 ms |
284016 KB |
Output is correct |
5 |
Correct |
2538 ms |
283980 KB |
Output is correct |
6 |
Correct |
2517 ms |
284100 KB |
Output is correct |
7 |
Correct |
2906 ms |
284008 KB |
Output is correct |
8 |
Correct |
2864 ms |
284100 KB |
Output is correct |
9 |
Correct |
2758 ms |
283884 KB |
Output is correct |