Submission #282204

# Submission time Handle Problem Language Result Execution time Memory
282204 2020-08-24T06:40:18 Z 반딧불(#5757) None (JOI15_memory) C++17
100 / 100
3031 ms 283948 KB
#include <bits/stdc++.h>
#include "Memory_lib.h"
#define ensure(x) if(!(x)) return -2;

int Memory(int n, int k){
    bool bit = k&1;
    int location = (k>>1)&127;
    int turn = (k>>8)&127;
    int stackSize = (k>>15)&127;
    location++;
    if(turn==0) turn++;

    ensure(1 <= location && location <= n && 1 <= turn && turn <= n && 0 <= stackSize && stackSize <= n/2);

    char tmp = Get(location);
    if(tmp == '>' || tmp == ']'){
        if(stackSize == 0) return -2;
        if(turn == stackSize){
            if(bit == 1 && tmp == '>') return -2;
            if(bit == 0 && tmp == ']') return -2;
            bit = 0;
        }
        stackSize--;
    }
    else{
        stackSize++;
        if(stackSize*2 > n) return -2;
        if(stackSize == turn){
            bit = (tmp == '<' ? 0 : 1);
        }
    }

    if(location == n){
        if(stackSize) return -2;
        location = 0, turn++;
    }
    if(turn == n+1) return -1;

    k = bit;
    k += (location<<1) + (turn<<8) + (stackSize << 15);
    return k;
}
# Verdict Execution time Memory Grader output
1 Correct 2934 ms 283844 KB Output is correct
2 Correct 2878 ms 283896 KB Output is correct
3 Correct 2899 ms 283948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2934 ms 283844 KB Output is correct
2 Correct 2878 ms 283896 KB Output is correct
3 Correct 2899 ms 283948 KB Output is correct
4 Correct 2891 ms 283616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2934 ms 283844 KB Output is correct
2 Correct 2878 ms 283896 KB Output is correct
3 Correct 2899 ms 283948 KB Output is correct
4 Correct 2891 ms 283616 KB Output is correct
5 Correct 2946 ms 283656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2934 ms 283844 KB Output is correct
2 Correct 2878 ms 283896 KB Output is correct
3 Correct 2899 ms 283948 KB Output is correct
4 Correct 2891 ms 283616 KB Output is correct
5 Correct 2946 ms 283656 KB Output is correct
6 Correct 2909 ms 283768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2926 ms 283768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2934 ms 283844 KB Output is correct
2 Correct 2878 ms 283896 KB Output is correct
3 Correct 2899 ms 283948 KB Output is correct
4 Correct 2891 ms 283616 KB Output is correct
5 Correct 2946 ms 283656 KB Output is correct
6 Correct 2909 ms 283768 KB Output is correct
7 Correct 2926 ms 283768 KB Output is correct
8 Correct 2975 ms 283692 KB Output is correct
9 Correct 3031 ms 283628 KB Output is correct