Submission #595815

# Submission time Handle Problem Language Result Execution time Memory
595815 2022-07-14T07:13:29 Z jamezzz None (JOI15_memory) C++17
0 / 100
1 ms 212 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;

int Memory(int N,int M){
	int cur=M&127;
	if(cur==N){
		int mode=(M>>21);
		if(mode==0)return N|(1<<21);
		int pos=(M>>7)&127;
		if(pos==N)return -1;
		int sum=(M>>14)&127;
		char c=Get(pos+1);
		if(c=='<'||c=='[')++sum;
		else --sum;
		if(sum<0)return -2;
		++pos;
		return N|(pos<<7)|(sum<<14)|(1<<21);
	}
	
	int mode=(M>>21);
	if(mode==1){//process cur element
		int cur=M&127;//current pos
		int type=(M>>7)&1;
		char c=Get(cur+1);
		if(c=='>'&&type==1)return -2;
		if(c==']'&&type==0)return -2;
		return (cur+1)|((cur+1)<<7);
	}
	else{
		int cur=M&127;//current pos
		int pos=(M>>7)&127;//top of stack?
		int sum=(M>>14)&127;//prefix sum
		if(pos>=N)return -2;
		assert(1<=pos+1&&pos+1<=N);
		int c=Get(pos+1);
		if(cur==pos){
			if(c=='<'||c=='[')return cur|(1<<21);
			if(cur==0)return -2;
			else return cur|((pos-1)<<7);
		}
		if(sum==0&&(c=='<'||c=='[')){
			if(c=='<'){
				return cur|(1<<21);
			}
			else{
				return cur|(1<<7)|(1<<21);
			}
		}
		if(c=='<'||c=='[')--sum;
		else ++sum;
		--pos;
		if(pos<0)return -2;
		return cur|(pos<<7)|(sum<<14);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -