Submission #282203

# Submission time Handle Problem Language Result Execution time Memory
282203 2020-08-24T06:38:21 Z 반딧불(#5757) None (JOI15_memory) C++17
10 / 100
3005 ms 284152 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 -1;
            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 2896 ms 284152 KB Output is correct
2 Incorrect 2922 ms 283840 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2896 ms 284152 KB Output is correct
2 Incorrect 2922 ms 283840 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2896 ms 284152 KB Output is correct
2 Incorrect 2922 ms 283840 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2896 ms 284152 KB Output is correct
2 Incorrect 2922 ms 283840 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3005 ms 283856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2896 ms 284152 KB Output is correct
2 Incorrect 2922 ms 283840 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -