Submission #282187

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

bool arr[16]; /// <> : 0, [] : 1

int Memory(int n, int k){
    int stackSize = 0;
    for(int i=0; i<16; i++){
        arr[i] = (k>>i) & 1;
        if(arr[i] == 1) stackSize = i;
    }
    arr[stackSize] = 0;

    int location = (k>>17) & 31;
    location++;

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

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

    k=0;
    arr[stackSize] = 1;
    for(int i=0; i<16; i++) if(arr[i]) k |= (1<<i);
    k += location << 17;

    return k;
}
# Verdict Execution time Memory Grader output
1 Correct 3231 ms 283832 KB Output is correct
2 Correct 3301 ms 283676 KB Output is correct
3 Correct 3534 ms 283776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3231 ms 283832 KB Output is correct
2 Correct 3301 ms 283676 KB Output is correct
3 Correct 3534 ms 283776 KB Output is correct
4 Correct 3648 ms 283864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3231 ms 283832 KB Output is correct
2 Correct 3301 ms 283676 KB Output is correct
3 Correct 3534 ms 283776 KB Output is correct
4 Correct 3648 ms 283864 KB Output is correct
5 Correct 4034 ms 283768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3231 ms 283832 KB Output is correct
2 Correct 3301 ms 283676 KB Output is correct
3 Correct 3534 ms 283776 KB Output is correct
4 Correct 3648 ms 283864 KB Output is correct
5 Correct 4034 ms 283768 KB Output is correct
6 Correct 4162 ms 283616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Wrong Answer [1]
# Verdict Execution time Memory Grader output
1 Correct 3231 ms 283832 KB Output is correct
2 Correct 3301 ms 283676 KB Output is correct
3 Correct 3534 ms 283776 KB Output is correct
4 Correct 3648 ms 283864 KB Output is correct
5 Correct 4034 ms 283768 KB Output is correct
6 Correct 4162 ms 283616 KB Output is correct
7 Incorrect 0 ms 256 KB Wrong Answer [1]