QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#23041#2894. 麻将模拟器mahjongWA 239ms89680kbC++146.5kb2022-03-11 16:54:062022-04-30 02:15:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 02:15:33]
  • 评测
  • 测评结果:WA
  • 用时:239ms
  • 内存:89680kb
  • [2022-03-11 16:54:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int now,dir=1;
int nowpaidui,DP[2000005][5][2],pw[12];
int CNT[2000005];
inline void init()
{
	pw[0]=1;
	for(int i=1;i<=10;i++) pw[i]=pw[i-1]*5;
	for(int i=0;i<=2000000;i++)
	{
		for(int j=0;j<=4;j++) DP[i][j][0]=DP[i][j][1]=1e9;
		int x=i;
		while(x) CNT[i]+=x%5,x/=5;
	}
	DP[0][0][0]=0;
	for(int i=0;i<=2000000;i++)
	{
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				if(DP[i][x][y]) continue;
				if(!y) for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X<=2) DP[i+qwq*2][x][y+1]=min(DP[i+qwq*2][x][y+1],DP[i][x][y]);
				}
				if(x<4)
				{
					for(int k=0;k<=8;k++)
					{
						int X=(i/pw[k])%5,qwq=(pw[k]);
						if(X<=1) DP[i+qwq*3][x+1][y]=min(DP[i+qwq*3][x+1][y],DP[i][x][y]);
					}
					for(int k=0;k<=6;k++)
					{
						int X=(i/pw[k])%5,Y=(i/pw[k+1])%5,Z=(i/pw[k+2])%5,qwq=(pw[k]);
						if(X<=3&&Y<=3&&Z<=3) DP[i+qwq*31][x+1][y]=min(DP[i+qwq*31][x+1][y],DP[i][x][y]);
					}
				}
			}
		}
	}
	for(int i=0;i<=2000000;i++)
	{
		if(CNT[i]>14) continue;
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X>=1) DP[i][x][y]=min(DP[i-qwq][x][y],DP[i][x][y]);
				}
			}
		}
	}
	for(int i=2000000;i>=0;i--)
	{
		if(CNT[i]>14) continue;
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X>=1) DP[i-qwq][x][y]=min(DP[i-qwq][x][y],DP[i][x][y]+1);
				}
			}
		}
	}
}
string paidui[200];
inline int trans(string s)
{
	if(s=="PASS") return 42;
	if(s=="REVERSE") return 44;
	if(s=="DOUBLE") return 46;
	if(s=="E") return 31;
	if(s=="S") return 32;
	if(s=="W") return 33;
	if(s=="N") return 34;
	if(s=="B") return 35;
	if(s=="F") return 36;
	if(s=="Z") return 37;
	if(s[1]=='M') return s[0]-'0';
	if(s[1]=='P') return s[0]-'0'+10;
	return s[0]-'0'+20;
}
inline string TRANS(int s)
{
	if(s==42) return "PASS";
	if(s==44) return "REVERSE";
	if(s==46) return "DOUBLE";
	if(s==31) return "E";
	if(s==32) return "S";
	if(s==33) return "W";
	if(s==34) return "N";
	if(s==35) return "B";
	if(s==36) return "F";
	if(s==37) return "Z";
	string rtn;
	rtn+=(char)(s%10+'0');
	if(s<=10) rtn+='M';
	else if(s<=20) rtn+='P';
	else rtn+='S';
	return rtn;
}
struct pai
{
	int cnt[50]={},fulu=0;
	string name;
	inline int dist()
	{
		int dp[5][2];
		for(int i=0;i<=4;i++) dp[i][0]=dp[i][1]=1e9;
		dp[0][0]=0;
		int qwq=0;
		for(int i=1;i<=9;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		qwq=0;
		for(int i=11;i<=19;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		qwq=0;
		for(int i=21;i<=29;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		for(int x=31;x<=37;x++)
		{
			for(int i=4;i>=0;i--) for(int j=1;j>=0;j--)
			{
				if(i!=4) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+3-min(3,cnt[x]));
				if(j!=1) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+2-min(2,cnt[x]));
			}
		}
		return dp[4-fulu][1];
	}
	inline void zimo()
	{
		if(dist()==0)
		{
			cout << name << " " << "SELFDRAWN\n";
			cout << name << " " << "WIN\n"; 
			exit(0);
		}
	}
	inline void mopai()
	{
		if(nowpaidui==148)
		{
			cout << "DRAW";
			exit(0);
		}
		cout << name+" IN " << paidui[++nowpaidui] << "\n";
		++cnt[trans(paidui[nowpaidui])];
		zimo();
	}
	inline int chupai()
	{
		if(cnt[42])
		{
			--cnt[42];
			now=(now+dir)%4;
			now=(now+dir)%4;
			return 42;
		}
		if(cnt[44])
		{
			--cnt[44];
			dir=4-dir;
			now=(now+dir)%4;
			return 44;
		}
		if(cnt[46])
		{
			--cnt[46];
			return 46;
		}
		now=(now+dir)%4;
		int mn=1e9,pos=42;
		for(int i=40;i>=0;i--) 
		{
			if(cnt[i])
			{
				--cnt[i];
				int x=dist();
				++cnt[i];
				if(x<mn) mn=x,pos=i;
			//	if(name=="C") cout << name << " " << x << "qwqwqwqwqwqwqwq" << pos << "\n"; 
			}
		}
		--cnt[pos];
		return pos;
	}
	inline bool chow(int x)
	{
		if(x>=30) return 0;
		int lst=dist();
		if(cnt[x+1]&&cnt[x+2])
		{
			--cnt[x+1],--cnt[x+2],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x)+" "+TRANS(x+1)+" "+TRANS(x+2)+"\n";
				return 1; 
			}
			++cnt[x+1],++cnt[x+2],--fulu;
		}
		if(cnt[x+1]&&cnt[x-1])
		{
			--cnt[x+1],--cnt[x-1],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x-1)+" "+TRANS(x)+" "+TRANS(x+1)+"\n";
				return 1; 
			}
			++cnt[x+1],++cnt[x-1],--fulu;
		}
		if(cnt[x-2]&&cnt[x-1])
		{
			--cnt[x-2],--cnt[x-1],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x-2)+" "+TRANS(x-1)+" "+TRANS(x)+"\n";
				return 1; 
			}
			++cnt[x-2],++cnt[x-1],--fulu;
		}
		return 0;
	}
	inline void print()
	{
		for(int i=1;i<=48;i++)
		{
			for(int j=1;j<=cnt[i];j++)
				cout << TRANS(i) << " ";
		}
		cout << "\n";
	}
}a[4];
inline int pong(int x)
{
	if(x>38) return -1;
	for(int i=0;i<4;i++)
	{
		if(a[i].cnt[x]>=2)
		{
			int lst=a[i].dist();
			a[i].cnt[x]-=2;
			++a[i].fulu;
			if(a[i].dist()>=lst)
			{
				--a[i].fulu;
				a[i].cnt[x]+=2;
			}
			else
			{
				cout << a[i].name << " PONG " << TRANS(x)+" "+TRANS(x)+" "+TRANS(x)+"\n";
				now=i;
				return i;
			}
		}
	}
	return -1;
}
inline void ron(int x)
{
	for(int i=0;i<4;i++)
	{
		++a[i].cnt[x];
		if(a[i].dist()==0)
		{
			cout << a[i].name << " " << "RON\n";
			cout << a[i].name << " " << "WIN\n"; 
			exit(0);
		}
		--a[i].cnt[x];
	}
}
signed main()
{
	a[0].name="A";
	a[1].name="B";
	a[2].name="C";
	a[3].name="D";
	init();
	for(int i=1;i<=148;i++)
		cin >> paidui[i];
	now=0,dir=1;
	for(int i=1;i<=52;i++)
	{
		a[now].mopai();
		now=(now+dir)%4;
	}
//	a[0].print();
//	cout << a[2].dist() << "**************************";
//	cout << DP[pw[2]+pw[3]+pw[4]+pw[6]+pw[8]][1][0] << "\n"; 
	int flag=1;
	while(1)
	{
		if(flag) a[now].mopai();
		flag=1;
		int lst=now,x=a[now].chupai();
	//	--a[lst].cnt[x];
		cout << a[lst].name << " OUT " << TRANS(x);
		if(TRANS(x)=="PASS") cout << " " << a[(lst+dir)%4].name;
		cout << "\n";
		ron(x);
		int nx=pong(x);
		if(nx!=-1) now=nx,flag=0;
		else if(a[now].chow(x)) flag=0;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 208ms
memory: 89628kb

input:

8M
Z
E
9P
3P
9S
5P
W
3M
8P
DOUBLE
5P
Z
2P
3M
8S
2S
5P
5M
E
6M
9S
6P
5S
7M
4S
3S
6M
3S
2M
9M
5S
Z
7P
5P
8M
3M
F
7M
2S
N
4P
3S
S
PASS
1P
6S
3P
9P
9S
4M
8P
N
Z
N
5M
DOUBLE
REVERSE
S
3P
4M
4S
1S
PASS
4P
6S
7S
7P
6S
9M
REVERSE
3P
7P
DOUBLE
B
9P
4S
5S
7S
7S
7P
6S
9S
B
9M
S
F
2P
1P
PASS
9P
DOUBLE
4P
PASS
5...

output:

A IN 8M
B IN Z
C IN E
D IN 9P
A IN 3P
B IN 9S
C IN 5P
D IN W
A IN 3M
B IN 8P
C IN DOUBLE
D IN 5P
A IN Z
B IN 2P
C IN 3M
D IN 8S
A IN 2S
B IN 5P
C IN 5M
D IN E
A IN 6M
B IN 9S
C IN 6P
D IN 5S
A IN 7M
B IN 4S
C IN 3S
D IN 6M
A IN 3S
B IN 2M
C IN 9M
D IN 5S
A IN Z
B IN 7P
C IN 5P
D IN 8M
A IN 3M
B IN F...

result:

ok 84 lines

Test #2:

score: 0
Accepted
time: 202ms
memory: 89624kb

input:

REVERSE
4S
8S
6P
4P
F
1P
W
9P
N
9M
B
7S
5P
PASS
5M
7M
9S
1S
2P
3S
6S
B
2S
9P
9M
4S
3M
W
6P
8P
W
2M
7P
6M
8M
2S
S
F
W
DOUBLE
E
2P
E
2M
8S
2S
9P
1M
7S
8M
N
4P
1S
1P
S
3P
3S
B
3M
7P
5S
3M
5M
7M
2S
E
9P
1M
7P
3P
5P
REVERSE
5S
9S
8M
4M
7P
1S
7M
1M
1M
8P
9S
6M
7S
PASS
4M
3M
9M
B
2P
4P
6S
F
4S
6P
6P
7M
1S
...

output:

A IN REVERSE
B IN 4S
C IN 8S
D IN 6P
A IN 4P
B IN F
C IN 1P
D IN W
A IN 9P
B IN N
C IN 9M
D IN B
A IN 7S
B IN 5P
C IN PASS
D IN 5M
A IN 7M
B IN 9S
C IN 1S
D IN 2P
A IN 3S
B IN 6S
C IN B
D IN 2S
A IN 9P
B IN 9M
C IN 4S
D IN 3M
A IN W
B IN 6P
C IN 8P
D IN W
A IN 2M
B IN 7P
C IN 6M
D IN 8M
A IN 2S
B IN...

result:

ok 175 lines

Test #3:

score: 0
Accepted
time: 203ms
memory: 89596kb

input:

6M
5S
2S
8S
5S
N
W
5S
6P
9P
3S
6S
8P
7P
5M
5M
7M
2S
4S
5M
REVERSE
F
9S
REVERSE
7S
B
2S
4M
3S
6P
2P
3M
N
8M
9M
REVERSE
7P
PASS
2S
1P
1M
N
8M
7M
W
1S
4M
2M
PASS
W
6P
7M
7P
3P
9S
4M
B
4S
6M
8S
6S
3P
2M
9S
9S
1S
1M
1P
2P
1S
2P
4P
9P
8P
S
9M
F
7S
1M
9P
E
S
8P
Z
8M
1P
2M
F
4P
B
DOUBLE
4S
E
3P
7S
DOUBLE
9P...

output:

A IN 6M
B IN 5S
C IN 2S
D IN 8S
A IN 5S
B IN N
C IN W
D IN 5S
A IN 6P
B IN 9P
C IN 3S
D IN 6S
A IN 8P
B IN 7P
C IN 5M
D IN 5M
A IN 7M
B IN 2S
C IN 4S
D IN 5M
A IN REVERSE
B IN F
C IN 9S
D IN REVERSE
A IN 7S
B IN B
C IN 2S
D IN 4M
A IN 3S
B IN 6P
C IN 2P
D IN 3M
A IN N
B IN 8M
C IN 9M
D IN REVERSE
A ...

result:

ok 168 lines

Test #4:

score: 0
Accepted
time: 205ms
memory: 89596kb

input:

6S
2S
5M
8P
5P
F
B
F
3S
8P
5P
9M
4S
6S
3S
Z
S
2P
2M
4S
2P
9S
4S
4P
2S
7S
REVERSE
3M
2M
E
9P
4P
9P
W
E
6P
PASS
S
2M
1M
3S
B
7M
3P
7S
DOUBLE
1S
6M
6P
Z
3P
5P
7S
9M
2P
6S
W
1M
S
E
REVERSE
1M
9M
W
PASS
1P
N
E
7P
1P
F
9S
9S
1P
W
8P
3P
N
3P
DOUBLE
4M
6M
2S
4M
1P
REVERSE
Z
B
6M
F
7M
5M
4M
3M
3S
S
DOUBLE
N
...

output:

A IN 6S
B IN 2S
C IN 5M
D IN 8P
A IN 5P
B IN F
C IN B
D IN F
A IN 3S
B IN 8P
C IN 5P
D IN 9M
A IN 4S
B IN 6S
C IN 3S
D IN Z
A IN S
B IN 2P
C IN 2M
D IN 4S
A IN 2P
B IN 9S
C IN 4S
D IN 4P
A IN 2S
B IN 7S
C IN REVERSE
D IN 3M
A IN 2M
B IN E
C IN 9P
D IN 4P
A IN 9P
B IN W
C IN E
D IN 6P
A IN PASS
B IN ...

result:

ok 128 lines

Test #5:

score: 0
Accepted
time: 209ms
memory: 89572kb

input:

5P
2P
5M
PASS
3S
8M
W
S
W
DOUBLE
9M
E
6S
9S
Z
4S
W
3S
6M
6S
DOUBLE
7M
1P
9M
9S
Z
9P
REVERSE
7M
1S
8S
2S
8P
DOUBLE
4S
4M
6S
3P
4S
3P
8S
REVERSE
1M
N
7M
8S
3P
6M
5P
3S
REVERSE
6P
N
6P
4P
PASS
E
8P
N
1S
9S
8M
7S
8P
3P
5M
6M
6M
9S
2M
6P
E
8P
PASS
2P
F
3M
N
1M
3M
B
F
1P
1P
1S
F
2S
5M
2S
4S
2M
4M
1M
2P
7P...

output:

A IN 5P
B IN 2P
C IN 5M
D IN PASS
A IN 3S
B IN 8M
C IN W
D IN S
A IN W
B IN DOUBLE
C IN 9M
D IN E
A IN 6S
B IN 9S
C IN Z
D IN 4S
A IN W
B IN 3S
C IN 6M
D IN 6S
A IN DOUBLE
B IN 7M
C IN 1P
D IN 9M
A IN 9S
B IN Z
C IN 9P
D IN REVERSE
A IN 7M
B IN 1S
C IN 8S
D IN 2S
A IN 8P
B IN DOUBLE
C IN 4S
D IN 4M
...

result:

ok 92 lines

Test #6:

score: 0
Accepted
time: 215ms
memory: 89584kb

input:

N
PASS
6S
4M
9M
1S
5M
5S
1S
7M
7S
2S
PASS
9S
4S
F
5P
7S
2S
5P
DOUBLE
5S
5M
2P
S
W
5S
4P
4S
9M
4P
3P
7S
REVERSE
8M
5P
6S
8M
7M
6M
3P
S
2S
2M
B
1P
6P
Z
6P
5M
6P
2P
2P
8M
2M
9M
4P
S
4S
Z
1M
2M
3M
6M
E
N
3M
8P
PASS
7M
6S
W
3S
4S
7P
3M
1M
1P
8P
F
W
Z
F
E
2M
9P
E
1S
B
7P
7P
Z
6P
5P
2P
F
4M
DOUBLE
1M
DOUBL...

output:

A IN N
B IN PASS
C IN 6S
D IN 4M
A IN 9M
B IN 1S
C IN 5M
D IN 5S
A IN 1S
B IN 7M
C IN 7S
D IN 2S
A IN PASS
B IN 9S
C IN 4S
D IN F
A IN 5P
B IN 7S
C IN 2S
D IN 5P
A IN DOUBLE
B IN 5S
C IN 5M
D IN 2P
A IN S
B IN W
C IN 5S
D IN 4P
A IN 4S
B IN 9M
C IN 4P
D IN 3P
A IN 7S
B IN REVERSE
C IN 8M
D IN 5P
A I...

result:

ok 98 lines

Test #7:

score: 0
Accepted
time: 222ms
memory: 89500kb

input:

9P
9P
3M
4S
E
6P
B
3S
5P
6M
2S
4P
9P
PASS
S
2S
B
9S
8P
4M
3P
5M
4P
1S
3S
N
3S
4M
1M
5M
1P
7S
9M
DOUBLE
6M
3M
9S
F
9P
4P
W
1P
Z
3S
DOUBLE
E
4M
6S
2P
5S
Z
7P
1S
4M
8S
5S
4P
1P
1M
2S
2S
5S
REVERSE
7M
B
5M
PASS
S
7M
2M
9M
8P
2M
E
N
6M
8S
7P
B
1S
7M
4S
7S
Z
3P
3M
8P
2M
DOUBLE
7P
PASS
2P
REVERSE
8S
F
3P
9...

output:

A IN 9P
B IN 9P
C IN 3M
D IN 4S
A IN E
B IN 6P
C IN B
D IN 3S
A IN 5P
B IN 6M
C IN 2S
D IN 4P
A IN 9P
B IN PASS
C IN S
D IN 2S
A IN B
B IN 9S
C IN 8P
D IN 4M
A IN 3P
B IN 5M
C IN 4P
D IN 1S
A IN 3S
B IN N
C IN 3S
D IN 4M
A IN 1M
B IN 5M
C IN 1P
D IN 7S
A IN 9M
B IN DOUBLE
C IN 6M
D IN 3M
A IN 9S
B I...

result:

ok 184 lines

Test #8:

score: 0
Accepted
time: 191ms
memory: 89680kb

input:

8M
PASS
1P
1S
5P
9S
3P
4P
4S
1P
7S
7S
2S
W
9M
F
4S
1S
1M
3S
6S
5S
PASS
3S
Z
B
5P
DOUBLE
2S
5S
E
1M
5S
F
9M
8S
2P
7P
5P
F
1P
3P
8S
1M
7S
REVERSE
7M
2M
1M
B
2M
6P
DOUBLE
4P
F
1P
3P
DOUBLE
PASS
2P
9S
4S
9S
2P
Z
3M
9P
8M
8P
6M
REVERSE
DOUBLE
Z
3M
N
4M
6M
B
6S
7M
S
4P
8P
6M
W
6P
E
5P
4M
9M
2M
Z
W
7P
PASS...

output:

A IN 8M
B IN PASS
C IN 1P
D IN 1S
A IN 5P
B IN 9S
C IN 3P
D IN 4P
A IN 4S
B IN 1P
C IN 7S
D IN 7S
A IN 2S
B IN W
C IN 9M
D IN F
A IN 4S
B IN 1S
C IN 1M
D IN 3S
A IN 6S
B IN 5S
C IN PASS
D IN 3S
A IN Z
B IN B
C IN 5P
D IN DOUBLE
A IN 2S
B IN 5S
C IN E
D IN 1M
A IN 5S
B IN F
C IN 9M
D IN 8S
A IN 2P
B ...

result:

ok 116 lines

Test #9:

score: 0
Accepted
time: 198ms
memory: 89528kb

input:

3S
6P
Z
7S
1P
Z
REVERSE
5M
1P
1S
7S
3M
3S
4S
1S
4S
4S
8P
8M
1P
2M
2M
6S
8S
9S
9P
E
F
2S
7P
3M
6P
9P
8P
4M
4P
S
9M
N
S
6S
3M
B
6M
7M
PASS
8P
6M
7M
8M
DOUBLE
2P
9S
W
5S
7P
4M
2S
1M
7S
4P
9M
2S
8S
1M
3P
5M
DOUBLE
9S
1S
7M
5P
W
9M
B
5P
6S
2M
DOUBLE
8S
5M
3S
8P
2P
E
5P
5S
4M
6P
3P
2P
REVERSE
9P
7P
F
9S
D...

output:

A IN 3S
B IN 6P
C IN Z
D IN 7S
A IN 1P
B IN Z
C IN REVERSE
D IN 5M
A IN 1P
B IN 1S
C IN 7S
D IN 3M
A IN 3S
B IN 4S
C IN 1S
D IN 4S
A IN 4S
B IN 8P
C IN 8M
D IN 1P
A IN 2M
B IN 2M
C IN 6S
D IN 8S
A IN 9S
B IN 9P
C IN E
D IN F
A IN 2S
B IN 7P
C IN 3M
D IN 6P
A IN 9P
B IN 8P
C IN 4M
D IN 4P
A IN S
B IN...

result:

ok 132 lines

Test #10:

score: 0
Accepted
time: 208ms
memory: 89668kb

input:

9P
2M
4S
6P
9M
S
5S
8P
REVERSE
5S
9P
8M
N
F
Z
7P
1M
DOUBLE
5P
2S
2P
8P
6S
3M
9M
N
N
6P
7S
S
2M
4M
3S
6S
8S
5M
1M
7P
1M
PASS
PASS
8P
5M
2S
1S
E
5M
PASS
W
B
3S
6P
9S
3P
W
8S
4M
8M
9S
7M
PASS
5M
6M
3S
7M
9S
9P
4P
4M
2S
7P
2S
9M
REVERSE
3P
W
4P
1P
2M
N
1S
8S
5P
6P
6S
DOUBLE
8P
REVERSE
7M
B
1S
F
4S
S
1P
...

output:

A IN 9P
B IN 2M
C IN 4S
D IN 6P
A IN 9M
B IN S
C IN 5S
D IN 8P
A IN REVERSE
B IN 5S
C IN 9P
D IN 8M
A IN N
B IN F
C IN Z
D IN 7P
A IN 1M
B IN DOUBLE
C IN 5P
D IN 2S
A IN 2P
B IN 8P
C IN 6S
D IN 3M
A IN 9M
B IN N
C IN N
D IN 6P
A IN 7S
B IN S
C IN 2M
D IN 4M
A IN 3S
B IN 6S
C IN 8S
D IN 5M
A IN 1M
B ...

result:

ok 164 lines

Test #11:

score: 0
Accepted
time: 222ms
memory: 89612kb

input:

7M
7M
Z
8M
PASS
2M
6P
F
5S
E
8S
3M
6P
3M
5M
2P
9S
2S
2S
Z
4M
9M
6M
REVERSE
3P
N
8S
S
3S
REVERSE
DOUBLE
7S
5S
5P
7M
W
W
5S
1M
7S
2P
1M
B
1P
7M
6P
6M
4P
6M
9S
5M
4M
4M
8S
8M
PASS
5P
1S
2P
5M
8P
PASS
3S
DOUBLE
8M
2P
8M
7S
6S
B
DOUBLE
2S
E
4P
B
4S
E
2M
7P
8P
5M
B
3M
F
E
9M
9S
S
3M
N
4P
4S
Z
7P
7P
1P
PAS...

output:

A IN 7M
B IN 7M
C IN Z
D IN 8M
A IN PASS
B IN 2M
C IN 6P
D IN F
A IN 5S
B IN E
C IN 8S
D IN 3M
A IN 6P
B IN 3M
C IN 5M
D IN 2P
A IN 9S
B IN 2S
C IN 2S
D IN Z
A IN 4M
B IN 9M
C IN 6M
D IN REVERSE
A IN 3P
B IN N
C IN 8S
D IN S
A IN 3S
B IN REVERSE
C IN DOUBLE
D IN 7S
A IN 5S
B IN 5P
C IN 7M
D IN W
A I...

result:

ok 160 lines

Test #12:

score: 0
Accepted
time: 213ms
memory: 89672kb

input:

8M
3P
4S
E
7S
9S
2M
Z
1P
8S
7M
DOUBLE
DOUBLE
DOUBLE
7P
7S
5P
1M
B
N
B
4M
1S
3M
9P
6S
9M
1P
REVERSE
8P
9S
7S
F
2M
1S
5P
8P
8P
7P
B
9P
9P
3M
REVERSE
3P
3M
3S
7P
5P
2P
W
6M
1M
6M
2S
6S
2P
8M
PASS
3S
F
4P
3P
PASS
REVERSE
4S
7P
7M
5M
4P
REVERSE
8M
W
E
5P
S
F
2P
9M
4M
2M
4P
5S
3S
2S
DOUBLE
9M
W
1P
1S
1M
9...

output:

A IN 8M
B IN 3P
C IN 4S
D IN E
A IN 7S
B IN 9S
C IN 2M
D IN Z
A IN 1P
B IN 8S
C IN 7M
D IN DOUBLE
A IN DOUBLE
B IN DOUBLE
C IN 7P
D IN 7S
A IN 5P
B IN 1M
C IN B
D IN N
A IN B
B IN 4M
C IN 1S
D IN 3M
A IN 9P
B IN 6S
C IN 9M
D IN 1P
A IN REVERSE
B IN 8P
C IN 9S
D IN 7S
A IN F
B IN 2M
C IN 1S
D IN 5P
A...

result:

ok 224 lines

Test #13:

score: 0
Accepted
time: 201ms
memory: 89608kb

input:

4P
8S
W
8S
1P
6M
E
B
5S
5S
5M
5S
DOUBLE
9P
9M
4M
4S
2M
4S
1M
1S
5M
1S
N
Z
F
3S
8S
3M
2P
9P
2M
7M
2M
8M
9S
4P
9M
S
8P
3P
S
DOUBLE
7P
9P
3P
5S
7P
9M
2S
5M
B
3P
6S
REVERSE
9S
7M
3S
9P
7P
F
1M
6M
6P
E
N
6M
3P
7S
4M
2S
DOUBLE
S
4P
F
7S
8P
5P
4P
7M
B
5P
3M
REVERSE
8M
1P
N
1M
1P
2S
3M
3S
8P
5M
8M
Z
E
8M
2M...

output:

A IN 4P
B IN 8S
C IN W
D IN 8S
A IN 1P
B IN 6M
C IN E
D IN B
A IN 5S
B IN 5S
C IN 5M
D IN 5S
A IN DOUBLE
B IN 9P
C IN 9M
D IN 4M
A IN 4S
B IN 2M
C IN 4S
D IN 1M
A IN 1S
B IN 5M
C IN 1S
D IN N
A IN Z
B IN F
C IN 3S
D IN 8S
A IN 3M
B IN 2P
C IN 9P
D IN 2M
A IN 7M
B IN 2M
C IN 8M
D IN 9S
A IN 4P
B IN 9...

result:

ok 164 lines

Test #14:

score: 0
Accepted
time: 207ms
memory: 89496kb

input:

5S
2M
7M
5M
2P
W
1M
REVERSE
W
5M
REVERSE
DOUBLE
4M
N
1S
5S
3M
2M
8P
7S
B
7P
9P
9S
6M
9M
F
8P
9M
2P
DOUBLE
Z
PASS
3S
PASS
9S
S
5P
1P
7M
2S
6P
2M
S
6M
6P
3S
8P
9M
4P
5P
2S
1M
1S
N
6M
8S
1M
8S
8M
3M
7M
S
7M
3S
S
9P
8P
5P
3P
7P
7P
9M
6S
5S
4M
9S
6P
REVERSE
8M
7S
1P
1M
3P
W
4M
1S
5S
8M
W
6S
REVERSE
E
3M
...

output:

A IN 5S
B IN 2M
C IN 7M
D IN 5M
A IN 2P
B IN W
C IN 1M
D IN REVERSE
A IN W
B IN 5M
C IN REVERSE
D IN DOUBLE
A IN 4M
B IN N
C IN 1S
D IN 5S
A IN 3M
B IN 2M
C IN 8P
D IN 7S
A IN B
B IN 7P
C IN 9P
D IN 9S
A IN 6M
B IN 9M
C IN F
D IN 8P
A IN 9M
B IN 2P
C IN DOUBLE
D IN Z
A IN PASS
B IN 3S
C IN PASS
D IN...

result:

ok 251 lines

Test #15:

score: 0
Accepted
time: 198ms
memory: 89676kb

input:

N
3P
W
1P
1M
2S
4M
S
7P
2S
7S
1S
7P
9M
6P
F
2M
5M
4S
7M
3M
8M
7M
Z
E
7S
9M
8P
9M
B
7M
3P
1M
7S
B
Z
3P
4M
1P
4M
3S
W
8P
W
DOUBLE
E
4S
1S
9M
4S
6M
8S
DOUBLE
9S
PASS
8S
5S
DOUBLE
7S
5S
E
4M
3S
5S
N
F
8M
2M
REVERSE
5M
7P
6P
N
5P
3M
1M
5P
9P
8M
E
8S
9S
2P
B
1S
1P
Z
REVERSE
9S
F
PASS
4S
4P
S
5M
6S
2S
7M
9...

output:

A IN N
B IN 3P
C IN W
D IN 1P
A IN 1M
B IN 2S
C IN 4M
D IN S
A IN 7P
B IN 2S
C IN 7S
D IN 1S
A IN 7P
B IN 9M
C IN 6P
D IN F
A IN 2M
B IN 5M
C IN 4S
D IN 7M
A IN 3M
B IN 8M
C IN 7M
D IN Z
A IN E
B IN 7S
C IN 9M
D IN 8P
A IN 9M
B IN B
C IN 7M
D IN 3P
A IN 1M
B IN 7S
C IN B
D IN Z
A IN 3P
B IN 4M
C IN ...

result:

ok 251 lines

Test #16:

score: 0
Accepted
time: 239ms
memory: 89496kb

input:

7S
F
1M
7M
PASS
8S
1P
5S
4P
REVERSE
4P
4P
9M
PASS
7M
4S
2P
2P
3M
3M
1P
PASS
N
7P
9M
W
B
3S
Z
8M
DOUBLE
7S
S
8M
7P
B
1P
9P
3P
7M
4P
8S
9P
PASS
F
2S
9S
9S
9S
B
W
5S
2M
E
B
6M
5M
1P
6S
4M
3P
F
8M
1S
DOUBLE
9M
8M
4S
4M
7M
2P
2S
2M
8P
2M
Z
E
5P
5S
6P
7S
N
6M
3S
3S
3M
5M
REVERSE
S
REVERSE
8P
3P
1S
1S
REVE...

output:

A IN 7S
B IN F
C IN 1M
D IN 7M
A IN PASS
B IN 8S
C IN 1P
D IN 5S
A IN 4P
B IN REVERSE
C IN 4P
D IN 4P
A IN 9M
B IN PASS
C IN 7M
D IN 4S
A IN 2P
B IN 2P
C IN 3M
D IN 3M
A IN 1P
B IN PASS
C IN N
D IN 7P
A IN 9M
B IN W
C IN B
D IN 3S
A IN Z
B IN 8M
C IN DOUBLE
D IN 7S
A IN S
B IN 8M
C IN 7P
D IN B
A IN...

result:

ok 253 lines

Test #17:

score: 0
Accepted
time: 205ms
memory: 89612kb

input:

7M
1S
1S
4M
6S
7M
7S
W
2P
4P
REVERSE
W
4S
N
S
DOUBLE
W
8S
Z
3M
3S
PASS
7M
8S
3P
1P
B
N
8P
W
PASS
6M
3S
2M
7P
3M
2S
1M
PASS
4S
4M
5M
DOUBLE
3P
9M
9S
1M
7M
3P
7S
8M
9M
2S
Z
5S
Z
6P
9P
4P
E
S
7S
7S
5P
9S
B
5S
4P
5M
2P
1M
8S
9S
9P
F
5M
6P
REVERSE
8M
E
8P
4S
DOUBLE
F
6M
B
9M
2S
9P
2M
4S
4M
4M
REVERSE
PAS...

output:

A IN 7M
B IN 1S
C IN 1S
D IN 4M
A IN 6S
B IN 7M
C IN 7S
D IN W
A IN 2P
B IN 4P
C IN REVERSE
D IN W
A IN 4S
B IN N
C IN S
D IN DOUBLE
A IN W
B IN 8S
C IN Z
D IN 3M
A IN 3S
B IN PASS
C IN 7M
D IN 8S
A IN 3P
B IN 1P
C IN B
D IN N
A IN 8P
B IN W
C IN PASS
D IN 6M
A IN 3S
B IN 2M
C IN 7P
D IN 3M
A IN 2S
...

result:

ok 255 lines

Test #18:

score: 0
Accepted
time: 216ms
memory: 89616kb

input:

8S
E
5S
2S
6M
9S
3M
7S
8P
4S
S
N
2S
E
7P
DOUBLE
5P
F
9P
2M
8P
3S
F
DOUBLE
S
2M
1S
3M
6P
DOUBLE
3S
E
REVERSE
N
3S
7P
8S
3P
Z
4S
1P
4S
1M
8S
B
8M
4P
5S
8M
4M
5M
7M
B
8P
7P
3M
Z
4P
DOUBLE
6M
7M
PASS
8S
2P
W
B
6P
6P
PASS
6M
2M
6S
4P
5S
2S
F
N
9S
2S
9P
9S
8M
S
7S
7M
5P
7M
9M
3S
9S
9P
S
B
1P
1M
REVERSE
1S...

output:

A IN 8S
B IN E
C IN 5S
D IN 2S
A IN 6M
B IN 9S
C IN 3M
D IN 7S
A IN 8P
B IN 4S
C IN S
D IN N
A IN 2S
B IN E
C IN 7P
D IN DOUBLE
A IN 5P
B IN F
C IN 9P
D IN 2M
A IN 8P
B IN 3S
C IN F
D IN DOUBLE
A IN S
B IN 2M
C IN 1S
D IN 3M
A IN 6P
B IN DOUBLE
C IN 3S
D IN E
A IN REVERSE
B IN N
C IN 3S
D IN 7P
A IN...

result:

ok 251 lines

Test #19:

score: 0
Accepted
time: 237ms
memory: 89672kb

input:

8P
S
4M
8M
PASS
6S
4P
B
S
7P
6S
4M
9P
6P
F
7P
DOUBLE
5P
W
9P
4M
9M
3M
3S
5S
5P
6M
4P
7M
W
8P
1P
Z
8S
3M
1M
W
3S
Z
9S
4S
7S
Z
5M
9S
7S
4S
7M
7P
9P
2S
REVERSE
4S
7P
PASS
6S
1P
5M
4P
DOUBLE
5S
N
9S
6P
6M
B
1M
5S
2S
1M
7S
2M
REVERSE
1P
6P
PASS
F
W
1S
1S
1M
2M
4S
9P
8S
2P
9M
E
8M
2P
8M
N
8M
7S
2M
S
6M
3S...

output:

A IN 8P
B IN S
C IN 4M
D IN 8M
A IN PASS
B IN 6S
C IN 4P
D IN B
A IN S
B IN 7P
C IN 6S
D IN 4M
A IN 9P
B IN 6P
C IN F
D IN 7P
A IN DOUBLE
B IN 5P
C IN W
D IN 9P
A IN 4M
B IN 9M
C IN 3M
D IN 3S
A IN 5S
B IN 5P
C IN 6M
D IN 4P
A IN 7M
B IN W
C IN 8P
D IN 1P
A IN Z
B IN 8S
C IN 3M
D IN 1M
A IN W
B IN 3...

result:

ok 236 lines

Test #20:

score: 0
Accepted
time: 219ms
memory: 89676kb

input:

6P
2S
8M
4P
REVERSE
1S
3M
7P
S
E
4S
REVERSE
6S
S
5M
4M
7M
6P
DOUBLE
Z
9P
PASS
6M
4S
W
S
9M
7S
5S
2P
W
5S
1P
Z
3M
6P
N
2P
2S
3P
1M
B
8M
PASS
3S
2M
8S
9S
3S
8P
6S
3M
F
5M
6M
1M
6S
4S
N
5P
E
2S
5M
6S
9S
2P
1P
B
5P
DOUBLE
F
7P
N
8P
DOUBLE
8S
1S
Z
6P
4M
7S
2S
3P
9S
5S
7P
7P
6M
1M
E
DOUBLE
4S
8M
5P
5M
2M
...

output:

A IN 6P
B IN 2S
C IN 8M
D IN 4P
A IN REVERSE
B IN 1S
C IN 3M
D IN 7P
A IN S
B IN E
C IN 4S
D IN REVERSE
A IN 6S
B IN S
C IN 5M
D IN 4M
A IN 7M
B IN 6P
C IN DOUBLE
D IN Z
A IN 9P
B IN PASS
C IN 6M
D IN 4S
A IN W
B IN S
C IN 9M
D IN 7S
A IN 5S
B IN 2P
C IN W
D IN 5S
A IN 1P
B IN Z
C IN 3M
D IN 6P
A IN...

result:

ok 146 lines

Test #21:

score: -100
Wrong Answer
time: 213ms
memory: 89520kb

input:

2P
3P
3S
2M
E
4S
1P
5S
DOUBLE
5P
1S
2P
9S
6P
9M
1S
4P
Z
N
4S
S
8M
PASS
PASS
8M
6S
7M
4M
6M
9P
DOUBLE
1P
1M
3S
Z
Z
3M
2S
6P
8S
S
5S
W
8S
3P
1S
6P
E
9P
F
4P
7M
4P
F
3M
8P
6M
N
1P
1P
7P
W
2P
5P
4S
5M
7M
9S
5P
5S
2P
N
S
5M
4M
9M
5M
8P
7S
7S
3P
REVERSE
B
F
4M
F
DOUBLE
2M
7P
6P
3M
9P
B
8S
5P
DOUBLE
7M
6S
...

output:

A IN 2P
B IN 3P
C IN 3S
D IN 2M
A IN E
B IN 4S
C IN 1P
D IN 5S
A IN DOUBLE
B IN 5P
C IN 1S
D IN 2P
A IN 9S
B IN 6P
C IN 9M
D IN 1S
A IN 4P
B IN Z
C IN N
D IN 4S
A IN S
B IN 8M
C IN PASS
D IN PASS
A IN 8M
B IN 6S
C IN 7M
D IN 4M
A IN 6M
B IN 9P
C IN DOUBLE
D IN 1P
A IN 1M
B IN 3S
C IN Z
D IN Z
A IN 3...

result:

wrong answer 165th lines differ - expected: 'C RON', found: 'A RON'