Submission #213324

# Submission time Handle Problem Language Result Execution time Memory
213324 2020-03-25T14:36:18 Z zimpha None (JOI15_memory) C++17
100 / 100
2865 ms 283644 KB
#include "Memory_lib.h"
/*
#include <cstdio>
#include <cstring>

char s[1000];

char Get(int i) {
  return s[i - 1];
}
*/

int Memory(int N, int M) {
  if (N % 2 == 1) return -2;
  int call = M % (1 << 13);
  int d = call / N + 1, i = call % N;
  if (d > N / 2) return -1;
  int cnt = (M >> 13) % (1 << 7);
  int rec = (M >> 20);
  if (cnt > N / 2) return -2;
  char c = Get(i + 1);
  if (c == '<' || c == '[') {
    ++cnt;
    if (cnt == d) rec = (c == '<');
  } else {
    if (cnt == d) {
      if (rec && c != '>') return -2;
      if (!rec && c != ']') return -2;
    }
    cnt--;
  }
  if (cnt < 0) return -2;
  if (i == N - 1 && cnt != 0) return -2;
  call++;
  return call + (cnt << 13) + (rec << 20);
}
/*
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int m = 0;
  int cnt = 0;
  for (; cnt < 15000; ++cnt) {
    m = Memory(n, m);
    if (m < 0) break;
  }
  printf("%d\n", m);
  return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 2755 ms 283512 KB Output is correct
2 Correct 2769 ms 283644 KB Output is correct
3 Correct 2751 ms 283640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2755 ms 283512 KB Output is correct
2 Correct 2769 ms 283644 KB Output is correct
3 Correct 2751 ms 283640 KB Output is correct
4 Correct 2770 ms 283512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2755 ms 283512 KB Output is correct
2 Correct 2769 ms 283644 KB Output is correct
3 Correct 2751 ms 283640 KB Output is correct
4 Correct 2770 ms 283512 KB Output is correct
5 Correct 2755 ms 283512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2755 ms 283512 KB Output is correct
2 Correct 2769 ms 283644 KB Output is correct
3 Correct 2751 ms 283640 KB Output is correct
4 Correct 2770 ms 283512 KB Output is correct
5 Correct 2755 ms 283512 KB Output is correct
6 Correct 2778 ms 283640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2865 ms 283640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2755 ms 283512 KB Output is correct
2 Correct 2769 ms 283644 KB Output is correct
3 Correct 2751 ms 283640 KB Output is correct
4 Correct 2770 ms 283512 KB Output is correct
5 Correct 2755 ms 283512 KB Output is correct
6 Correct 2778 ms 283640 KB Output is correct
7 Correct 2865 ms 283640 KB Output is correct
8 Correct 2777 ms 283640 KB Output is correct
9 Correct 2858 ms 283640 KB Output is correct