제출 #217492

#제출 시각아이디문제언어결과실행 시간메모리
217492EntityIT기억 압축 (JOI15_memory)C++14
0 / 100
5 ms384 KiB
#include<bits/stdc++.h>
using namespace std;

#include "Memory_lib.h"

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

const int LIM = (1 << 7) - 1;
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );

int Memory(int N, int M) {
    int checkedDep = M & LIM,
        dep = (M >> 7) & LIM,
        pos = ( (M >> 14) & LIM) + 1,
        lst = M >> 21;
    
    char tmp = Get(pos);
    if (tmp == '<') {
        if (dep++ == checkedDep) lst = 0;
    }
    else if (tmp == '>') {
        if (--dep == checkedDep) {
            if (lst) return -2;
        }
    }
    else if (tmp == '[') {
        if (dep++ == checkedDep) lst = 1;
    }
    else {
        if (--dep == checkedDep) {
            if (!lst) return -2;
        }
    }
    if (dep < 0) return -2;

    if (pos == N) {
        if (dep) return -2;
        else {
            if (checkedDep == N >> 1) return -1;
            ++checkedDep;
            pos = 0;
        }
    }

    return checkedDep | (dep << 7) | (pos << 14) | (lst << 21);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...