Submission #95434

# Submission time Handle Problem Language Result Execution time Memory
95434 2019-02-01T07:11:41 Z Retro3014 None (JOI15_memory) C++17
0 / 100
2294 ms 276676 KB
#include "Memory_lib.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>

using namespace std;



int Memory(int N, int M) {
	//cout<<N<<" "<<M<<endl;
	if(M==0){
		return (3<<20);
	}
	int k = (M>>20);
	int t = M%(1<<20);
	int a = t/10000, b = (t/100)%100, c = (t%100);
	if(a>N-1 || b>N-1 || c>N-1)	return -2;
	char ch = Get(b+1);
	//cout<<k<<" "<<a<<" "<<b<<" "<<c<<" "<<ch<<endl;
	if(k==3){
		if(ch=='<'){
			a++;
		}else if(ch=='>'){
			a--; if(a<0)	return -2;
		}else if(ch=='['){
			c++;
		}else{
			c--; if(c<0)	return -2;
		}
		if(b==N+1){
			if(a!=0 || c!=0)	return -2;
			return (1<<20);
		}
		b++;
		int K = (k<<20) + a*10000 + b*100 + c;
		return K;
	}
	if(b==0 && k!=0){
		k = 0;
	}
	if(a==0){
		if(k==0){
			if(ch=='<')	k = 1;
			else if(ch=='[')	k = 2;
		}else{
			return -2;/*
			if(k==1){
				if(c!=0 || ch!='>'){
					return -2;
				}
			}else{
				if(c!=0 || ch!=']'){
					return -2;
				}
			}
			k = 0;
			c = 0;*/
		}
	}
	if(k==0){
		if(ch=='<' || ch=='['){
			a--;
			if(a<0)	return -2;
		}
		else{
			a++;
		}	
	}
	if(k!=0){
		if(ch=='<' || ch=='['){
			a++;
		}
		else{
			a--;
			if(a<0)	return -2;
		}	
		if(k==1){
			if(ch=='<'){
				c++;
			}else if(ch=='>'){
				c--;
				if(c<0)	return -2;
			}
		}else{
			if(ch=='['){
				c++;
			}else if(ch==']'){
				c--;
				if(c<0)	return -2;
			}
		}
		if(a==0 || c==0){
			if(a!=0 || c!=0)	return -2;
			k = 0;
		}
	}
	if(b==N-1){
		if(k!=0)	return -2;
		if(a==N-1)	return -1;
		b = 0;
		a++;
		c = 0;
	}else{
		b++;
	}
	int K = (k<<20) + a*10000 + b*100 + c;
	return K;
}
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 276676 KB Output is correct
2 Incorrect 2163 ms 276632 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 276676 KB Output is correct
2 Incorrect 2163 ms 276632 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 276676 KB Output is correct
2 Incorrect 2163 ms 276632 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 276676 KB Output is correct
2 Incorrect 2163 ms 276632 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2294 ms 276600 KB Wrong Answer [6]
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 276676 KB Output is correct
2 Incorrect 2163 ms 276632 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -