답안 #282215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282215 2020-08-24T06:55:37 Z 최은수(#5756) 기억 압축 (JOI15_memory) C++17
100 / 100
2980 ms 283948 KB
#include"Memory_lib.h"
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mx=128;
int Memory(int N,int M)
{
    if(N%2==1)
        return-2;
    int stt=M/mx/mx/2;
    int right=M/mx/2%mx;
    int left=M/2%mx;
    int lget=M%2;
    if(stt>N||left>N||right>N)
        return-2;
    if(left==0)
    {
        lget=2;
        stt=0;
    }
    if(stt==0)
    {
        if(right==N)
            return left==0?-1:-2;
        char c=Get(++right);
        if(c=='['||c=='<')
        {
            int v=c=='['?0:1;
            left=right;
            lget=v;
        }
        else
        {
            int v=c==']'?0:1;
            if(lget!=v)
                return-2;
            left--;
            stt=1;
        }
    }
    else
    {
        char c=Get(left--);
        if(c==']'||c=='>')
            stt++;
        else
        {
            if(--stt==0)
                lget=c=='['?0:1,left++;
        }
    }
    return lget+left*2+right*2*mx+stt*2*mx*mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2857 ms 283948 KB Output is correct
2 Correct 2895 ms 283896 KB Output is correct
3 Correct 2864 ms 283772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2857 ms 283948 KB Output is correct
2 Correct 2895 ms 283896 KB Output is correct
3 Correct 2864 ms 283772 KB Output is correct
4 Correct 2902 ms 283656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2857 ms 283948 KB Output is correct
2 Correct 2895 ms 283896 KB Output is correct
3 Correct 2864 ms 283772 KB Output is correct
4 Correct 2902 ms 283656 KB Output is correct
5 Correct 2904 ms 283892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2857 ms 283948 KB Output is correct
2 Correct 2895 ms 283896 KB Output is correct
3 Correct 2864 ms 283772 KB Output is correct
4 Correct 2902 ms 283656 KB Output is correct
5 Correct 2904 ms 283892 KB Output is correct
6 Correct 2879 ms 283684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2980 ms 283820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2857 ms 283948 KB Output is correct
2 Correct 2895 ms 283896 KB Output is correct
3 Correct 2864 ms 283772 KB Output is correct
4 Correct 2902 ms 283656 KB Output is correct
5 Correct 2904 ms 283892 KB Output is correct
6 Correct 2879 ms 283684 KB Output is correct
7 Correct 2980 ms 283820 KB Output is correct
8 Correct 2942 ms 283700 KB Output is correct
9 Correct 2973 ms 283700 KB Output is correct