#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 sz, int mch, int st)
{
return (st<<8)|(mch<<4)|(sz);
}
int Memory(int N, int M)
{
if(N%2) return -2;
int sz=M&15; M>>=4;
int mch=M&15; M>>=4;
int st=M;
if(sz>N/2) return -2;
if(mch>N/2) return -2;
if(st>=(1<<(N/2))) return -2;
if(mch*2+sz>=N) return -2;
char c=Get(mch*2+sz+1);
if(c=='<')
{
st<<=1;
sz++;
if(sz>N/2) return -2;
}
else if(c=='[')
{
st<<=1;
st|=1;
sz++;
if(sz>N/2) return -2;
}
else if(c=='>')
{
if(sz==0) return -2;
if((st&1)!=0) return -2;
sz--; st>>=1; mch++;
}
else if(c==']')
{
if(sz==0) return -2;
if((st&1)!=1) return -2;
sz--; st>>=1; mch++;
}
if(mch*2+sz==N)
{
if(sz==0) return -1;
return -2;
}
return encode(sz, mch, st);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2807 ms |
283808 KB |
Output is correct |
2 |
Correct |
2834 ms |
284024 KB |
Output is correct |
3 |
Correct |
2842 ms |
284000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2807 ms |
283808 KB |
Output is correct |
2 |
Correct |
2834 ms |
284024 KB |
Output is correct |
3 |
Correct |
2842 ms |
284000 KB |
Output is correct |
4 |
Correct |
3132 ms |
283872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2807 ms |
283808 KB |
Output is correct |
2 |
Correct |
2834 ms |
284024 KB |
Output is correct |
3 |
Correct |
2842 ms |
284000 KB |
Output is correct |
4 |
Correct |
3132 ms |
283872 KB |
Output is correct |
5 |
Correct |
2956 ms |
283660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2807 ms |
283808 KB |
Output is correct |
2 |
Correct |
2834 ms |
284024 KB |
Output is correct |
3 |
Correct |
2842 ms |
284000 KB |
Output is correct |
4 |
Correct |
3132 ms |
283872 KB |
Output is correct |
5 |
Correct |
2956 ms |
283660 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2807 ms |
283808 KB |
Output is correct |
2 |
Correct |
2834 ms |
284024 KB |
Output is correct |
3 |
Correct |
2842 ms |
284000 KB |
Output is correct |
4 |
Correct |
3132 ms |
283872 KB |
Output is correct |
5 |
Correct |
2956 ms |
283660 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |