답안 #163189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163189 2019-11-11T17:57:02 Z TadijaSebez 기억 압축 (JOI15_memory) C++11
100 / 100
2741 ms 283968 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
//-------------------------------//
/*
string s;
int n;
int wa=0;
bool was;
char Get(int i)
{
	if(i<1 || i>n) wa=1;
	if(was) wa=6;
	was=1;
	return s[i-1];
}
*/
//-------------------------------//
int Memory(int n, int m)
{
	auto Build=[](int l, int r, int b, int t){ return l+r*128+b*128*128+t*128*128*128;};
	int l=m%128;
	int r=(m/128)%128;
	int b=(m/128/128)%128;
	int t=(m/128/128/128)%2;
	if(l>n || r>n+1 || b>n) return 0;
	if(l==0)
	{
		l=1,b=1;
		char c=Get(1);
		if(c=='>' || c==']') r=l-1;
		else r=l+1;
		if(c=='<' || c=='>') t=1;
		else t=0;
		return Build(l,r,b,t);
	}
	if(b==0)
	{
		l++;b=1;
		if(l>n) return -1;
		char c=Get(l);
		if(c=='>' || c==']') r=l-1;
		else r=l+1;
		if(c=='<' || c=='>') t=1;
		else t=0;
		return Build(l,r,b,t);
	}
	else
	{
		if(r==0 || r==n+1){ Get(1);return -2;}
		if(l<r)
		{
			char c=Get(r);r++;
			if(c=='>' || c==']') b--;
			else b++;
			if(b==0)
			{
				if(t==1 && c==']') return -2;
				if(t==0 && c=='>') return -2;
			}
			return Build(l,r,b,t);
		}
		else
		{
			char c=Get(r);r--;
			if(c=='<' || c=='[') b--;
			else b++;
			if(b==0)
			{
				if(t==1 && c=='[') return -2;
				if(t==0 && c=='<') return -2;
			}
			return Build(l,r,b,t);
		}
	}
}
//-------------------------------//
/*
int Play()
{
	int m=0,potez;
	wa=0;
	for(potez=1;potez<=15000;potez++)
	{
		was=0;
		m=Memory(n,m);
		if(wa) return -3;
		if(m>=(1<<22)){ wa=2;return -3;}
		if(m<=-3){ wa=3;return m;}
		if(m<0) break;
	}
	if(potez>15000) wa=4;
	return m;
}
void Run(string f)
{
	ifstream in(f+".in"),sol(f+".txt");
	int t;
	in>>n>>t;
	int cnt_wa[7]={0};
	for(int i=1;i<=t;i++)
	{
		in>>s;
		int out=Play();
		int ans;sol>>ans;
		if(!wa && out!=ans) wa=5;
		cnt_wa[wa]++;
	}
	cout<<f<<": ";
	for(int i=0;i<=6;i++) cout<<cnt_wa[i]<<" ";
	cout<<endl;
}
int main()
{
	set<string> st={"sample-01","01-01","01-02","01-03","02-01","03-01","04-01","05-01","06-01","06-02"};
	for(string f:st) Run(f);
	return 0;
}
*/
//-------------------------------//
# 결과 실행 시간 메모리 Grader output
1 Correct 2566 ms 282332 KB Output is correct
2 Correct 2697 ms 283968 KB Output is correct
3 Correct 2570 ms 283680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2566 ms 282332 KB Output is correct
2 Correct 2697 ms 283968 KB Output is correct
3 Correct 2570 ms 283680 KB Output is correct
4 Correct 2657 ms 283856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2566 ms 282332 KB Output is correct
2 Correct 2697 ms 283968 KB Output is correct
3 Correct 2570 ms 283680 KB Output is correct
4 Correct 2657 ms 283856 KB Output is correct
5 Correct 2593 ms 283836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2566 ms 282332 KB Output is correct
2 Correct 2697 ms 283968 KB Output is correct
3 Correct 2570 ms 283680 KB Output is correct
4 Correct 2657 ms 283856 KB Output is correct
5 Correct 2593 ms 283836 KB Output is correct
6 Correct 2609 ms 283716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2728 ms 283708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2566 ms 282332 KB Output is correct
2 Correct 2697 ms 283968 KB Output is correct
3 Correct 2570 ms 283680 KB Output is correct
4 Correct 2657 ms 283856 KB Output is correct
5 Correct 2593 ms 283836 KB Output is correct
6 Correct 2609 ms 283716 KB Output is correct
7 Correct 2728 ms 283708 KB Output is correct
8 Correct 2741 ms 283624 KB Output is correct
9 Correct 2722 ms 283624 KB Output is correct