Submission #282847

#TimeUsernameProblemLanguageResultExecution timeMemory
282847arnold518기억 압축 (JOI15_memory)C++14
0 / 100
3031 ms283876 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int encode(int type, int top, int pos, int off) { int ret=0; ret|=type; ret<<=7; ret|=top; ret<<=7; ret|=pos; ret<<=6; ret|=off; return ret; } int Memory(int N, int M) { if(N%2) return -2; if(M==0) return encode(0, 0, 1, 0); int type, top, pos, off; off=M&((1<<6)-1); M>>=6; pos=M&((1<<7)-1); M>>=7; top=M&((1<<7)-1); M>>=7; //printf("%d %d %d %d\n", type, top, pos, off); type=M; if(!(top<pos)) return -2; if(!(1<=pos && pos<=N+1)) return -2; if(!(1<=top && top<=N+1)) return -2; if(!(off>N/2)) return -2; if(type==0) { if(off!=0) return -2; if(pos==N+1) { if(top==0) return -1; return -2; } if(!(1<=pos && pos<=N)) return -2; char c=Get(pos); if(c=='>') return encode(1, top, pos, 0); if(c==']') return encode(2, top, pos, 0); if(c=='<') return encode(0, pos, pos+1, 0); if(c=='[') return encode(0, pos, pos+1, 0); } else if(type==1) { if(top==0) return -2; if(!(1<=top && top<=N)) return -2; char c=Get(top); if(c!='<') return -2; return encode(3, top-1, pos+1, 0); } else if(type==2) { if(top==0) return -2; if(!(1<=top && top<=N)) return -2; char c=Get(top); if(c!='[') return -2; return encode(3, top-1, pos+1, 0); } else { char c; if(top==0) c='<'; else if(top<=N) c=Get(top); else return -2; if(c==']' || c=='>') off++; else off--; if(off<0) return encode(0, top, pos, 0); return encode(3, top-1, pos, off); } }

Compilation message (stderr)

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:79:1: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      | ^
#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...