Submission #677387

# Submission time Handle Problem Language Result Execution time Memory
677387 2023-01-03T07:27:29 Z qwerasdfzxcl None (JOI15_memory) C++17
0 / 100
268 ms 33464 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
struct Data{
    int x, y, z, w;
    Data(){}
    Data(int _x, int _y, int _z, int _w): x(_x), y(_y), z(_z), w(_w) {}
};

Data decode(int M){
    return Data((M&(127<<15))>>15, (M&(127<<8))>>8, (M&(127<<1))>>1, M&1);
}

int encode(int x, int y, int z, int w){
    return (x<<15) | (y<<8) | (z<<1) | w;
}

int Memory(int N, int M) {
    if (M==0) return encode(1, 1, 0, 0);
    auto [s, cur, sum, typ] = decode(M);
    //printf(" %d %d %d %d\n", s, cur, sum, typ);
    if (s==N+1) return -1;
    if (cur >= N+1 || cur <= 0) return -2;

    char x = Get(cur);
    if (s==cur){
        if (x=='>' || x==']') return encode(s, s-1, 1, x==']');
        return encode(s, s+1, 1, x=='[');
    }

    if ((x=='>' || x==']') == (s<cur)) sum -= 1;
    else sum += 1;

    //printf(" sum = %d\n", sum);

    if (sum==0){
        int typ2 = (x=='[' || x==']');
        //printf(" typ = %d / typ2 = %d\n", typ, typ2);
        if (typ==typ2) return encode(s+1, s+1, 0, 0);
        return -2;
    }

    int delta = (s<cur)?1:-1;
    return encode(s, cur+delta, sum, typ);
}
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 33464 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 33464 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 33464 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 33464 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 33464 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -