Submission #1037149

#TimeUsernameProblemLanguageResultExecution timeMemory
1037149beaconmc기억 압축 (JOI15_memory)C++14
0 / 100
0 ms348 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> typedef int ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) using namespace std; int encode(int a, int b, int c, int d, int e){ return a + b*(1<<7) + c*(1<<14) + d*(1<<20) + e*(1<<21); } vector<int> decode(int k){ ll a,b,c,d,e; a = k%(1<<7); b = (k>>7)%(1<<7); c = (k>>14)%(1<<6); d = (k>>20)%(1<<1); e = (k>>21); return {a,b,c,d,e}; } int Memory(int N, int M) { vector<int> sus = decode(M); ll a,b,c,d,e; a = sus[0];b=sus[1];c=sus[2];d=sus[3],e=sus[4]; //cout << a << " " << b << " " << c << " " << d << " " << e << endl; if (e==0){ if (c==N){ if (a!=b) return -2; else return encode(0,0,0,0,1); } else{ char temp = Get(c+1); c++; if (temp == '<' || temp == '[') a++; else b++; } return encode(a,b,c,d,e); }else{ if (a==b){ if (b+1 > N){ if (d==1) return -1; return -2; } char temp = Get(b+1); if (temp == '>'){ d = 0; b += 1; }else if (temp == ']'){ d = 1; b += 1; }else{ a = b+1; b = b+1; d = 0; } }else{ char temp = Get(a); if (temp == ']' || temp == '>'){ c += 1; a-=1; } else{ if (c==0){ if (temp == '<' && d==0){ a = b; b = b; d = 1; } else if (temp == '[' && d==1){ a = b; b = b; d = 1; } else return -2; }else{ c-=1; a-=1; } } } if (a<=0) return -2; if (a==b && a==N+1) return -1; else return encode(a,b,c,d,e); } }
#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...