# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037142 | beaconmc | 기억 압축 (JOI15_memory) | C++14 | 0 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Memory_lib.h"
#include <bits/stdc++.h>
typedef long long 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){
return a + b*(1<<7) + c*(1<<14) + d*(1<<21);
}
vector<int> decode(int k){
ll a,b,c,d;
a = k%(1<<7);
b = (k>>7)%(1<<7);
c = (k>>14)%(1<<7);
d = (k>>21);
return {a,b,c,d};
}
int Memory(int N, int M) {
vector<int> sus = decode(M);
ll a,b,c,d;
a = sus[0];b=sus[1];c=sus[2];d=sus[3];
//cout << a << " " << b << " " << c << " " << d << endl;
if (a==b){
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;
}
}else{
char temp = Get(a);
if (temp == ']' || temp == '>'){
c += 1;
a-=1;
}
else{
if (c==0){
if (temp == '<' && d==0){
a = b+1;
b = b+1;
}
else if (temp == '[' && d==1){
a = b+1;
b = b+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);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |