Submission #592526

#TimeUsernameProblemLanguageResultExecution timeMemory
592526tqbfjotld기억 압축 (JOI15_memory)C++14
40 / 100
2480 ms284084 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> using namespace std; int Memory(int N, int M) { if (N>30){ int loc = M%(N+1); int rem = M/(N+1); if (loc==N) return rem==0?-1:-2; int res = Get(loc+1); if (res=='>'){ if (rem==0) return -2; rem--; } else{ rem++; } if ((rem*(N+1)+loc+1)>=(1<<22)) return -2; return rem*(N+1)+loc+1; } int loc = M%(N+1); int rem = M/(N+1); if (loc==0) rem = 1<<15; int rems = 15-__builtin_ctz(rem); if (rems<0) return -2; int remm = rem>>(15-rems+1); if (loc==N){ return rems==0?-1:-2; } int res = Get(loc+1); //printf("loc %d rems = %d remm = %x\n",loc,rems,remm); if (res==']' || res=='>'){ if (rems==0) return -2; if ((remm&1)==(res==']')){ rems--; remm>>=1; } else{ return -2; } } else{ if (rems==15){ return -2; } rems++; remm<<=1; remm += (res=='['); } if ((((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1))>=(1<<22)) return -2; //printf("rems = %d, remm = %x\n",rems,remm); return ((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1); }
#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...