Submission #56887

# Submission time Handle Problem Language Result Execution time Memory
56887 2018-07-13T05:15:32 Z 강태규(#1633) None (JOI15_memory) C++11
30 / 100
3482 ms 276876 KB
#include "Memory_lib.h"

int Memory(int N, int M) {
    if (N <= 30) {
        int i = M >> 16;
        M &= ((1 << 16) - 1);
        if (N <= i) {
            if (M != 1) return -2;
            return -1;
        }
        int sz = 15;
        while (sz > 0 && (M >> sz) == 0) --sz;
        M &= ((1 << sz) - 1);
        
        char ret = Get(i + 1);
        
        switch (ret) {
        case '<':
            if (sz == 15) return -2;
            return ((i + 1) << 16) | (2 << sz) | M;
            break;
        case '>':
            if (sz == 0 || (M >> (sz - 1))) return -2;
            return ((i + 1) << 16) | (1 << (sz - 1)) | M;
            break;
        case '[':
            if (sz == 15) return -2;
            return ((i + 1) << 16) | (3 << sz) | M;
            break;
        case ']':
            if (sz > 0 && (M >> (sz - 1)))
                return ((i + 1) << 16) | (1 << (sz - 1)) | M;
            return -2;
            break;
        }
    }
    int i = M >> 16;
    int x = M & ((1 << 16) - 1);
    if (N <= i) {
        if (x != 0) return -2;
        return -1;
    }
    
    if (Get(i + 1) != '<') {
        if (--x < 0) return -2;
    }
    else {
        ++x;
    }
    return ((i + 1) << 16) | x;
}
# Verdict Execution time Memory Grader output
1 Correct 2928 ms 276704 KB Output is correct
2 Correct 3108 ms 276788 KB Output is correct
3 Correct 3482 ms 276788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2928 ms 276704 KB Output is correct
2 Correct 3108 ms 276788 KB Output is correct
3 Correct 3482 ms 276788 KB Output is correct
4 Correct 2722 ms 276788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2928 ms 276704 KB Output is correct
2 Correct 3108 ms 276788 KB Output is correct
3 Correct 3482 ms 276788 KB Output is correct
4 Correct 2722 ms 276788 KB Output is correct
5 Correct 3286 ms 276800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2928 ms 276704 KB Output is correct
2 Correct 3108 ms 276788 KB Output is correct
3 Correct 3482 ms 276788 KB Output is correct
4 Correct 2722 ms 276788 KB Output is correct
5 Correct 3286 ms 276800 KB Output is correct
6 Correct 3391 ms 276876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 276876 KB Wrong Answer [1]
# Verdict Execution time Memory Grader output
1 Correct 2928 ms 276704 KB Output is correct
2 Correct 3108 ms 276788 KB Output is correct
3 Correct 3482 ms 276788 KB Output is correct
4 Correct 2722 ms 276788 KB Output is correct
5 Correct 3286 ms 276800 KB Output is correct
6 Correct 3391 ms 276876 KB Output is correct
7 Incorrect 46 ms 276876 KB Wrong Answer [1]