Submission #1156337

#TimeUsernameProblemLanguageResultExecution timeMemory
1156337modwwe기억 압축 (JOI15_memory)C++20
0 / 100
1 ms324 KiB
#include "Memory_lib.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
///#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r)
{
    return uniform_int_distribution<int>(l,r)(rd);
}
void phongbeo();
const int inf = 1e9;
const ll mod2 = 998244353;
const ll base=67;
int  n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r,dem5,dem6,dem7,dem9;
int kk;
int t;
int el = 19;/*
main()
{
    if(fopen(task2".inp","r"))
    {
        fin(task2);
        fou(task2);
    }
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    /// cin>>s1;
//int t;cin>>t; while(t--)
    phongbeo();
    //  checktime
}
#define MAX_N 100
#define FORMAT_S "%101s"
#define LENGTH_S 102
#define LIMIT_M 4194304  // 2^22
#define MAX_NUM_DAYS 15000

static int N, Q;
static char S[LENGTH_S];

static void Wrong(int message)
{
    printf("Wrong Answer [%d]\n", message);
    exit(0);
}

static int get_called;
static int get_I;

char Get(int I)
{
    if (get_called)
    {
        Wrong(2);
    }
    get_called = 1;
    get_I = I;
    if (!(1 <= I && I <= N))
    {
        Wrong(3);
    }
    return S[I - 1];
}
string s;
char Get(int x)
{
    return s[x-1];
}*/
int f(int x,int y,int z,int c)
{
    return ((x*(n+2)+y)*(n+2)+z)*(n+2)+c;
}
int Memory(int N,int M)
{
    if(n%2==1) return -2;
    n=N;
    m=M;
    if(m==0)return f(0,0,1,1);
    int pos=m%(n+2);
    m/=(n+2);
    int id=m%(n+2);
    m/=(n+2);
    int val=m%(n+2);
    m/=(n+2);
    int col=m%(n+2);
    if(pos==n+1)
    {
        char x=Get(1);
        return -1;
    }
    if(col==0)
    {
        char x=Get(pos);
        if(x=='<'||x=='[')val++;
        else val--;
        if(val<0)return -2;
        if(val>n/2)return -2;
        if(pos==n)
        {
            if(val==0)return f(1,0,1,1);
            return -2;
        }
        return f(0,val,0,pos+1);
    }
    else
    {
        if(id<pos)
        {
            char x=Get(id);
            if(x=='<'||x=='[')val--;
            else val++;
            if(val==0)
            {
                if(x=='<'&&col==1)return f(1,0,pos+1,pos+1);
                if(x=='['&&col==2)return f(1,0,pos+1,pos+1);
                return -2;
            }
            return f(col,val,id-1,pos);
        }
        else if(id==pos)
        {
            char x=Get(pos);
            if(x=='<'||x=='[') return f(1,0,pos+1,pos+1);
            if(x=='>')return f(1,1,pos-1,pos);
            return f(2,1,pos-1,pos);
        }
    }
}/*
void phongbeo()
{
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
    int M;
    int test_index;
    int num_days;

    if (scanf("%d%d", &N, &Q) != 2)
    {
        fprintf(stderr, "error: cannot read N, Q\n");
        exit(1);
    }
    if (!(1 <= N && N <= MAX_N))
    {
        fprintf(stderr, "error: N is out of bounds\n");
        exit(1);
    }
    if (Q < 0)
    {
        fprintf(stderr, "error: Q is out of bounds\n");
        exit(1);
    }

    for (test_index = 0; test_index < Q; ++test_index)
    {
        if (scanf(FORMAT_S, S) != 1)
        {
            fprintf(stderr, "error: cannot read S\n");
            exit(1);
        }
        if (N != (int)strlen(S))
        {
            fprintf(stderr, "error: the length of S is not N\n");
            exit(1);
        }
        num_days = 0;
        M = 0;
        for (; ; )
        {
            get_called = 0;
            get_I = 0;
            M = Memory(N, M);
            if (!((0 <= M && M < LIMIT_M) || M == -1 || M == -2))
            {
                Wrong(1);
            }
            if (M == -1 || M == -2)
            {
                break;
            }
            if (++num_days >= 50)
            {
                Wrong(5);
            }
        }
        printf("%d\n", M);
    }

}
*/

Compilation message (stderr)

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:150:1: warning: control reaches end of non-void function [-Wreturn-type]
  150 | }/*
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...