# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
592602 |
2022-07-09T10:38:02 Z |
tqbfjotld |
None (JOI15_memory) |
C++14 |
|
2359 ms |
284144 KB |
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
int Memory(int N, int M) {
int cur = M%N;
int nowat = (M/N)%N;
int rem = M/N/N;
int dir = rem&1;
rem>>=1;
int typ = rem&1;
rem >>=1;
int height = rem;
if (M==160){
//printf("%d %d %d %d %d\n",cur,nowat,dir,typ,height);
}
if (cur>=N || nowat>=N) return -2;
assert(height>=0 && true);
if (cur==nowat){
char res = Get(cur+1);
//if (M==160)printf("received %c\n",res);
if (res=='[' || res=='<'){
dir = 1;
}
else{
dir = 0;
}
if (res=='<' || res=='>'){
typ = 0;
}
else{
typ = 1;
}
nowat += dir?1:-1;
if (nowat<0 || nowat>=N) return -2;
height = 1;
}
else{
if (height==0) return -2;
char res = Get(nowat+1);
//if (M==100)printf("received %c\n",res);
if (res=='[' || res=='<'){
if (dir==0){
height--;
if (height==0){
if (typ==(res=='[')){
cur = cur+1;
nowat = cur;
dir = 0;
typ = 0;
height = 0;
}
else{
return -2;
}
}
else{
nowat--;
if (nowat<0) return -2;
}
}
else{
height++;
if (height>50) return -2;
nowat++;
if (nowat>=N) return -2;
}
}
else{
if (dir==1){
height--;
if (height==0){
if (typ==(res==']')){
cur = cur+1;
nowat = cur;
dir = 0;
typ = 0;
height = 0;
}
else{
return -2;
}
}
else{
nowat++;
if (nowat>=N) return -2;
}
}
else{
height++;
if (height>50) return -2;
nowat--;
if (nowat<0) return -2;
}
}
}
assert(height>=0);
if (cur==N) return -1;
//if (M==160) printf("%d %d %d %d %d end\n",cur,nowat,dir,typ,height);
int retv = ((height*4+typ*2+dir)*N+nowat)*N+cur;
if (retv>=(1<<22)) return -2;
return retv;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2301 ms |
284144 KB |
Output is correct |
2 |
Correct |
2359 ms |
284112 KB |
Output is correct |
3 |
Correct |
2272 ms |
284024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2301 ms |
284144 KB |
Output is correct |
2 |
Correct |
2359 ms |
284112 KB |
Output is correct |
3 |
Correct |
2272 ms |
284024 KB |
Output is correct |
4 |
Correct |
2325 ms |
283940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2301 ms |
284144 KB |
Output is correct |
2 |
Correct |
2359 ms |
284112 KB |
Output is correct |
3 |
Correct |
2272 ms |
284024 KB |
Output is correct |
4 |
Correct |
2325 ms |
283940 KB |
Output is correct |
5 |
Correct |
2237 ms |
283900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2301 ms |
284144 KB |
Output is correct |
2 |
Correct |
2359 ms |
284112 KB |
Output is correct |
3 |
Correct |
2272 ms |
284024 KB |
Output is correct |
4 |
Correct |
2325 ms |
283940 KB |
Output is correct |
5 |
Correct |
2237 ms |
283900 KB |
Output is correct |
6 |
Correct |
2199 ms |
284084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2227 ms |
284080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2301 ms |
284144 KB |
Output is correct |
2 |
Correct |
2359 ms |
284112 KB |
Output is correct |
3 |
Correct |
2272 ms |
284024 KB |
Output is correct |
4 |
Correct |
2325 ms |
283940 KB |
Output is correct |
5 |
Correct |
2237 ms |
283900 KB |
Output is correct |
6 |
Correct |
2199 ms |
284084 KB |
Output is correct |
7 |
Correct |
2227 ms |
284080 KB |
Output is correct |
8 |
Correct |
2242 ms |
284028 KB |
Output is correct |
9 |
Correct |
2252 ms |
284028 KB |
Output is correct |