跳到正文

休闲·娱乐

十七步麻将 simulator 1.0

MatrixGroup约 36 分钟
原文
文章信息与版本

文章信息

发布
2024年3月13日
收录
2025年12月12日
更新
2026年8月25日
篇幅
约 36 分钟
获赞
1

版本

  1. v1当前

要求:两个人,一台电脑。

有表无赤无里。

C++
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,_##i##__end=int(n);i<_##i##__end;++i)
#define per(i,n) for(int i=int(n)-1;i>=0;--i)
#define rep1(i,n) for(int i=1,_##i##__end=int(n);i<=_##i##__end;++i)
#define per1(i,n) for(int i=int(n);i>=1;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
using namespace std;
const ll mod1=998244353;
const ll mod2=1000000007;
unsigned time_related_rand()
{
	return unsigned(std::chrono::steady_clock::now().time_since_epoch().count());
}
const int N=11;
const string name[N][34]={
"1m","2m","3m","4m","5m","6m","7m","8m","9m",
"1s","2s","3s","4s","5s","6s","7s","8s","9s",
"1p","2p","3p","4p","5p","6p","7p","8p","9p",
"1z","2z","3z","4z","5z","6z","7z",

"1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F","G","H","I",
"a","b","c","d","e","f","g","h","i",
"<","^",">","v","[","|","]",

"01","02","03","04","05","06","07","08","09",
"10","11","12","13","14","15","16","17","18",
"19","20","21","22","23","24","25","26","27",
"28","29","30","31","32","33","34",

"1万","2万","3万","4万","5万","6万","7万","8万","9万",
"1条","2条","3条","4条","5条","6条","7条","8条","9条",
"1筒","2筒","3筒","4筒","5筒","6筒","7筒","8筒","9筒",
"东 ","南 ","西 ","北 ","白 ","发 ","中",

"1万","2万","3万","4万","5万","6万","7万","8万","9万",
"1索","2索","3索","4索","5索","6索","7索","8索","9索",
"1筒","2筒","3筒","4筒","5筒","6筒","7筒","8筒","9筒",
"东 ","南 ","西 ","北 ","白 ","发 ","中",

"1万","2万","3万","4万","5万","6万","7万","8万","9万",
"1条","2条","3条","4条","5条","6条","7条","8条","9条",
"1饼","2饼","3饼","4饼","5饼","6饼","7饼","8饼","9饼",
"东 ","南 ","西 ","北 ","白 ","发 ","中",

"1万","2万","3万","4万","5万","6万","7万","8万","9万",
"1索","2索","3索","4索","5索","6索","7索","8索","9索",
"1饼","2饼","3饼","4饼","5饼","6饼","7饼","8饼","9饼",
"东 ","南 ","西 ","北 ","白 ","发 ","中",

"一万","二万","三万","四万","五万","六万","七万","八万","九万",
"一条","二条","三条","四条","五条","六条","七条","八条","九条",
"一筒","二筒","三筒","四筒","五筒","六筒","七筒","八筒","九筒",
"东风","南风","西风","北风","白板","发财","红中",

"一万","二万","三万","四万","五万","六万","七万","八万","九万",
"一索","二索","三索","四索","五索","六索","七索","八索","九索",
"一筒","二筒","三筒","四筒","五筒","六筒","七筒","八筒","九筒",
"东风","南风","西风","北风","白板","发财","红中",

"一万","二万","三万","四万","五万","六万","七万","八万","九万",
"一条","二条","三条","四条","五条","六条","七条","八条","九条",
"一饼","二饼","三饼","四饼","五饼","六饼","七饼","八饼","九饼",
"东风","南风","西风","北风","白板","发财","红中",

"一万","二万","三万","四万","五万","六万","七万","八万","九万",
"一索","二索","三索","四索","五索","六索","七索","八索","九索",
"一饼","二饼","三饼","四饼","五饼","六饼","七饼","八饼","九饼",
"东风","南风","西风","北风","白板","发财","红中",}; 
int Language;
const int dora[34]={1,2,3,4,5,6,7,8,0,10,11,12,13,14,15,16,17,9,19,20,21,22,23,24,25,26,18,28,29,30,27,32,33,31};
const int points[9]={8000,12000,16000,24000,32000,64000,96000,128000,160000};
const int M=2;
const string Name[M][9]={"满贯","跳满","倍满","三倍满","役满","两倍役满","三倍役满","四倍役满","五倍役满", 
"Mangan","Haneman","Baiman","Sanbaiman","Yakuman","Double Yakuman","Triple Yakuman","Quadruple Yakuman","Quintuple Yakuman"}; 
const string languages[M]={"简体中文","English"};
int tile[136];
int type;// of tile name
int pointsA;// points of player A
string s1,s2;// name 
int seed;
mt19937 myrand;
int t1[35],t2[35],indicator,realdora;
vector<int> h1,d1,h2,d2,discard;// handheld and discard
bool shunable[34]={
true,true,true,true,true,true,true,false,false,
true,true,true,true,true,true,true,false,false,
true,true,true,true,true,true,true,false,false,
false,false,false,false,false,false,false};// is shunzi ok
const int kokushi[13]={0,8,9,17,18,26,27,28,29,30,31,32,33};
int rnd(int l,int r)
{
	uniform_int_distribution<int> rng(l,r);
	return rng(myrand);
}
int fst;// the "dealer", 1 or 2
void Invalid()
{
	cout<<"404 not found. Where did you came in? "<<endl;system("pause");exit(0);
}
int Askfornumber(int l,int r)
{
	int ytq=2;
	switch(Language)
	{
		case 0:
			cout<<"请输入对应的数字 "<<endl;break;
		case 1:
			cout<<"Please type the corresponding number "<<endl;break;
		default:
			Invalid();
	}
	while(1)
	{
		cin>>ytq;
		if(l<=ytq&&ytq<=r) return ytq;
		switch(Language)
		{
			case 0:
				cout<<"请输入正确的数字 "<<endl;break;
			case 1:
				cout<<"Invalid option. Please try again. "<<endl;break;
			default:
				Invalid();
		}
	}
	return -1;
}
void CheckOne()
{
	if(Language==0)
	{
		cout<<"若确认,请输入数字 1。"<<endl;
		int x;
		while(1)
		{
			cin>>x;
			if(x==1) return ;
			cout<<"请确认。若确认,请输入数字 1。"<<endl;
		}
	}
	else
	{
		cout<<"If you check this, please type 1."<<endl;
		int x;
		while(1)
		{
			cin>>x;
			if(x==1) return ;
			cout<<"Please check it and type 1. "<<endl;
		}
	}
}
void Checkfirst()
{
	if(Language==0)
	{
		cout<<"请确认 "<<(fst==1?s1:s2)<<" 在看而 "<<(fst==1?s2:s1)<<" 不在看。"<<endl;
		CheckOne();
	}
	else
	{
		cout<<"Please check that "<<(fst==1?s1:s2)<<" is looking at the screen while "<<(fst==1?s2:s1)<<" is not."<<endl;
		CheckOne();
	}
}
void Checksecond()
{
	if(Language==0)
	{
		cout<<"请确认 "<<(fst==1?s2:s1)<<" 在看而 "<<(fst==1?s1:s2)<<" 不在看。"<<endl;
		CheckOne();
	}
	else
	{
		cout<<"Please check that "<<(fst==1?s2:s1)<<" is looking at the screen while "<<(fst==1?s1:s2)<<" is not."<<endl;
		CheckOne();
	}
}
void Checkboth()
{
	if(Language==0)
	{
		cout<<"请确认 "<<s1<<" 和 "<<s2<<" 都在看。"<<endl;
		CheckOne();
	}
	else
	{
		cout<<"Please check that both"<<s1<<" and "<<s2<<" is looking at the screen. "<<endl;
		CheckOne();
	}
}
void CheckSecond()
{
	if(Language==0)
	{
		cout<<"请确认 "<<(fst==1?s1:s2)<<" 在看而 "<<(fst==1?s2:s1)<<" 不在看。"<<endl;
		CheckOne();
	}
	else
	{
		cout<<"Please check that "<<(fst==1?s1:s2)<<" is looking at the screen while "<<(fst==1?s2:s1)<<" is not."<<endl;
		CheckOne();
	}
}
void PreCompute()
{
	system("cls");
	pointsA=0;
	rep(i,136)tile[i]=i/4;
	cout<<"17-step mahjong simulator 1.0 / 十七步麻将模拟器 1.0 "<<endl;
	cout<<"Please select your language / 请选择语言 "<<endl;
	for(int i=0;i<M;++i) cout<<i+1<<". "<<languages[i]<<endl;
	cout<<"Please type the corresponding number of your language / 请输入您语言对应的数字 "<<endl;
	while(1)
	{
		cin>>Language;--Language;
		if(0<=Language&&Language<M) break;
		cout<<"Invalid option. Please try again. / 请输入正确的数字 "<<endl;
	}
	if(Language==0)
	{
		system("cls");
		cout<<"十七步麻将 "<<endl;
		cout<<"请选择您想要的麻将显示格式: "<<endl;
		for(int i=0;i<N;++i)
		{
			cout<<i+1<<". ";
			for(int j=0;j<34;++j)
			{
				cout<<name[i][j];
				for(int k=int(name[i][j].size());k<5;++k)cout<<' ';
			}
			cout<<endl;
		}
		type=Askfornumber(1,N)-1;
		cout<<"请输入两玩家的昵称:"<<endl;
		cin>>s1>>s2;
		cout<<"请输入随机种子(范围为 0~1000000000,或 -1 表示根据当前时间生成)"<<endl;
		seed=Askfornumber(-1,1000000000);if(seed==-1){seed=int(time_related_rand()%1000000001);}
		myrand=mt19937(seed);
		system("cls");
		cout<<"设置完成。 "<<endl;
		cout<<"十七步麻将规则: "<<endl;
		cout<<"1. 有宝牌,无里宝牌,无红宝牌,不分庄闲,不能副露,不能暗杠,不能自摸,只能荣和。 "<<endl;
		cout<<"2. 第一巡强制立直,可以诈立直,流局不罚符,不算双立直,胡牌必须满贯及以上(可计宝牌)。 "<<endl;
		cout<<"3. 初始给定 34 张牌,选取 13 张作为手牌,剩下打 17 巡,留下 4 张不打。 "<<endl;
		cout<<"4. 立直后无论自己和对方打出的牌,只要能和(无论是否满贯),都计入振听,无法和牌。 "<<endl;
		cout<<"5. 点数申报自行完成,需要双方检查。立直无需立直棒。 "<<endl;
		cout<<"6. 有后付,无自摸损,无流局满贯,无途中流局,点数计算按照闲家算。 "<<endl;
		cout<<"7. 初始点数为 0,无击飞,自行决定何时结束。"<<endl;
		CheckOne();
	}
	else if(Language==1) 
	{
		system("cls");
		cout<<"17-step mahjong"<<endl;
		cout<<"Please choose how mahjong tiles are displayed: "<<endl;
		for(int i=0;i<N;++i)
		{
			cout<<i+1<<". ";
			for(int j=0;j<34;++j)
			{
				cout<<name[i][j];
				for(int k=int(name[i][j].size());k<5;++k)cout<<' ';
			}
			cout<<endl;
		}
		type=Askfornumber(1,N)-1;
		cout<<"Please type the name of the two players:"<<endl;
		cin>>s1>>s2;
		cout<<"Please type the random seed (ranged from 0 to 1000000000,or -1, which means the seed is generated according to the current time)"<<endl;
		seed=Askfornumber(-1,1000000000);if(seed==-1){seed=int(time_related_rand()%1000000001);}
		myrand=mt19937(seed);
		system("cls");
		cout<<"Settings done. "<<endl;
		cout<<"17-step mahjong rule: "<<endl;
		cout<<"1. There is dora, but no aka or ura dora. There is no dealer, and chi, pong, kang are not allowed. Only ron is allowed."<<endl;
		cout<<"2. Riichi is a must-done, whether you tenpai or not. There is no penalty when ryukyoku. Double riichi is not counted. Only mangan or above is allowed, where dora is counted."<<endl;
		cout<<"3. There are 34 tiles given at first, 13 of which are of handheld, 17 of which are to be played, and 4 of which are discarded."<<endl;
		cout<<"4. Tiles played by both yourself and the others one, if can be ronned (regardless of whether it is at least mangan), is counted as furiten and you cannot ron anymore."<<endl;
		cout<<"5. The points are calculated and checked by yourselves. No points is required by riichi."<<endl;
		cout<<"6. There is no ryukyoku mangan, halfway ryukyoku. The poins are calculated as if both players are not dealer."<<endl;
		cout<<"7. Both players start with 0 points, and there is no ending. You can decide when to end by yourselves."<<endl;
		CheckOne();
	}
	else
	{
		Invalid();
	}
}
vector<int> temp;
bool accept12(vector<int> V)
{
	if(int(V.size())!=12) return false;
	while(!V.empty())
	{
		if(V[0]==V[1]&&V[1]==V[2])
		{
			V.erase(V.begin());V.erase(V.begin());V.erase(V.begin());
		}
		else if(shunable[V[0]]&&find(V.begin(),V.end(),V[0]+1)!=V.end()&&find(V.begin(),V.end(),V[0]+2)!=V.end())
		{
			int x=V[0];
			V.erase(V.begin());V.erase(find(V.begin(),V.end(),x+1));V.erase(find(V.begin(),V.end(),x+2));
		}
		else
		{
			return false;
		}
	}
	return true;
}
vector<int> R;
bool chitoitsu(vector<int> Q)
{
	rep(i,7) if(Q[i<<1]!=Q[i<<1|1]) return false;
	rep(i,6) if(Q[i<<1|1]==Q[(i+1)<<1]) return false;
	return true;
}
bool kokushimusou(vector<int> Q)
{
	int r=0;for(int x:Q){int id=-1;rep(j,13)if(x==kokushi[j])id=j;if(id==-1) return false;r|=1<<id;}return r==8191; 
}
bool acceptable(vector<int> Q)
{
	sort(Q.begin(),Q.end());
	if(int(Q.size())!=14) return false;
	if(chitoitsu(Q)||kokushimusou(Q)) return true;
	rep(i,int(Q.size())-1)
	{
		if(Q[i]==Q[i+1])
		{
			R.clear();
			rep(j,int(Q.size()))if(j!=i&&j!=i+1)R.pb(Q[j]);
			if(accept12(R)) return true;
		}
	}
	return false;
}
bool accept(vector<int>X,int y)
{
	vector<int>T;T.clear();for(int c:X)T.pb(c);
	T.pb(y);return acceptable(T); 
}
bool Furiten1()
{
	for(int j:discard) if(accept(h1,j)) return true;
	return false;
}
bool Furiten2()
{
	for(int j:discard) if(accept(h2,j)) return true;
	return false;
}
void Game()
{
	system("cls");
	if(Language==0)
	{
		cout<<"种子: "<<seed<<endl;
		cout<<s1<<" : "<<pointsA<<endl;
		cout<<s2<<" : "<<-pointsA<<endl;
		cout<<"是否继续? 1. 继续 2. 结束"<<endl;
		int useless=Askfornumber(1,2);
		if(useless==2)
		{
			if(pointsA>0) cout<<s1<<" 赢了。"<<endl;
			else if(pointsA<0) cout<<s2<<" 赢了。"<<endl;
			else cout<<s1<<" 与 "<<s2<<" 打成平手。"<<endl;
			system("pause");exit(0);
		}
		fst=rnd(1,2);
		cout<<"本局 "<<(fst==1?s1:s2)<<" 先手。"<<endl;
		shuffle(tile,tile+136,myrand);
		rep(i,34) t1[i]=tile[i];
		rep(i,34) t2[i]=tile[i+34];
		sort(t1,t1+34);sort(t2,t2+34);
		indicator=tile[68];realdora=dora[indicator];
		cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
		cout<<"请 "<<(fst==1?s1:s2)<<" 观看自己手牌。"<<endl;Checkfirst();
		system("cls");cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
		rep(i,34) cout<<name[type][t1[i]]<<' ';cout<<endl;
		discard.clear();
		while(1)
		{
			h1.clear();d1.clear();
			rep(i,34)
			{
				cout<<"是否将 "<<name[type][t1[i]]<<" 加入初始手牌? 1. 加入 2. 放弃"<<endl;
				int x=Askfornumber(1,2);
				if(x==1) h1.pb(t1[i]);
				else d1.pb(t1[i]);
			}
			if(h1.size()!=13)
			{
				cout<<"初始手牌应当恰好有 13 张牌。请重新输入。"<<endl;
			}
			else
			{
				break;
			}
		}
		system("cls");
		cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
		cout<<"请 "<<(fst==2?s1:s2)<<" 观看自己手牌。"<<endl;Checksecond();
		rep(i,34) cout<<name[type][t2[i]]<<' ';cout<<endl;
		while(1)
		{
			h2.clear();d2.clear();
			rep(i,34)
			{
				cout<<"是否将 "<<name[type][t2[i]]<<" 加入初始手牌? 1. 加入 2. 放弃"<<endl;
				int x=Askfornumber(1,2);
				if(x==1) h2.pb(t2[i]);
				else d2.pb(t2[i]);
			}
			if(h2.size()!=13)
			{
				cout<<"初始手牌应当恰好有 13 张牌。请重新输入。"<<endl;
			}
			else
			{
				break;
			}
		}
		system("cls");
		cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
		cout<<"双方均已经检验手牌,并已立直。"<<endl;
		Checkboth();
		for(int _=1;_<=17;++_)
		{
			system("cls");
			cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<"第 "<<_<<" 巡。"<<endl;
			cout<<"已经出过的牌有:";for(int x:discard)cout<<' '<<name[type][x];cout<<endl;
			Checkboth();
			system("cls");cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<"请 "<<(fst==1?s1:s2)<<" 出牌。"<<endl;Checkfirst();
			cout<<"已经出过的牌有:";for(int x:discard)cout<<' '<<name[type][x];cout<<endl;
			cout<<"您的手牌是:";for(int x:h1)cout<<' '<<name[type][x];cout<<endl;
			cout<<"您可以出的牌有:";for(int i=0;i<int(d1.size());++i) cout<<"("<<i+1<<")"<<name[type][d1[i]];cout<<endl;
			cout<<"请选择您要出的牌的编号:"<<endl;int xt=Askfornumber(1,int(d1.size()))-1;
			int th=d1[xt];d1.erase(d1.begin()+xt);
			system("cls");
			cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<(fst==1?s1:s2)<<" 打出了 "<<name[type][th]<<endl;
			Checksecond(); 
			if(Furiten2())
			{
				cout<<"您已振听,请等待出牌。"<<endl;
				Checksecond();
			}
			else
			{
				cout<<"您的手牌是:";for(int x:h2)cout<<' '<<name[type][x];cout<<endl;
				cout<<"对方打出的是: "<<name[type][th]<<endl;
				cout<<"请问您是否要荣和?1. 荣和 2. 跳过"<<endl;int x=Askfornumber(1,2);
				if(x==1)
				{
					cout<<"类型是? 0. 错和(可撤回)";rep(i,9) cout<<i+1<<". "<<Name[Language][i];
					cout<<endl;int xd=Askfornumber(0,9);
					if(xd)
					{
						--xd;
						cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
						cout<<(fst==1?s2:s1)<<" 和出了 "<<Name[Language][xd]<<endl;
						cout<<"手牌:";rep(i,13) cout<<name[type][h2[i]]<<' ';
						cout<<endl;
						cout<<"和牌:"<<name[type][th]<<endl;
						cout<<(fst==1?s1:s2)<<" 手牌:";rep(i,13) cout<<name[type][h1[i]]<<' '; 
						Checkboth();
						cout<<"请 "<<(fst==1?s1:s2)<<" 确认点数。"<<endl;
						CheckOne();
						if(fst==2) pointsA+=points[xd];
						else pointsA-=points[xd];
						cout<<"本局结束。"<<endl;return ;
					}
				}
			}
			discard.pb(th);
			system("cls");
			cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<"第 "<<_<<" 巡。"<<endl;
			cout<<"已经出过的牌有:";for(int x:discard)cout<<' '<<name[type][x];cout<<endl;
			Checkboth();
			system("cls");cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<"请 "<<(fst==1?s2:s1)<<" 出牌。"<<endl;Checksecond();
			cout<<"已经出过的牌有:";for(int x:discard)cout<<' '<<name[type][x];cout<<endl;
			cout<<"您的手牌是:";for(int x:h2)cout<<' '<<name[type][x];cout<<endl;
			cout<<"您可以出的牌有:";for(int i=0;i<int(d2.size());++i) cout<<"("<<i+1<<")"<<name[type][d2[i]];cout<<endl;
			cout<<"请选择您要出的牌的编号:"<<endl;xt=Askfornumber(1,int(d2.size()))-1;
			th=d2[xt];d2.erase(d2.begin()+xt);
			system("cls");
			cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
			cout<<(fst==1?s2:s1)<<" 打出了 "<<name[type][th]<<endl;
			Checkfirst(); 
			if(Furiten1())
			{
				cout<<"您已振听,请等待出牌。"<<endl;
				Checkfirst();
			}
			else
			{
				cout<<"您的手牌是:";for(int x:h1)cout<<' '<<name[type][x];cout<<endl;
				cout<<"对方打出的是: "<<name[type][th]<<endl;
				cout<<"请问您是否要荣和?1. 荣和 2. 跳过"<<endl;int x=Askfornumber(1,2);
				if(x==1)
				{
					cout<<"类型是? 0. 错和(可撤回)";rep(i,9) cout<<i+1<<". "<<Name[Language][i];
					cout<<endl;int xd=Askfornumber(0,9);
					if(xd)
					{
						--xd;
						cout<<"本局的宝牌指示牌是 "<<name[type][indicator]<<",宝牌是 "<<name[type][realdora]<<endl;
						cout<<(fst==1?s1:s2)<<" 和出了 "<<Name[Language][xd]<<endl;
						cout<<"手牌:";rep(i,13) cout<<name[type][h1[i]]<<' ';
						cout<<endl;
						cout<<"和牌:"<<name[type][th]<<endl;
						cout<<(fst==1?s2:s1)<<" 手牌:";rep(i,13) cout<<name[type][h2[i]]<<' '; 
						Checkboth();
						cout<<"请 "<<(fst==1?s2:s1)<<" 确认点数。"<<endl;
						CheckOne();
						if(fst==2) pointsA-=points[xd];
						else pointsA+=points[xd];
						cout<<"本局结束。"<<endl;return ;
					}
				}
			}
			discard.pb(th);
		}
		cout<<"流局,无点数变化。"<<endl;
		cout<<(fst==1?s1:s2)<<" 手牌:";for(int x:h1)cout<<' '<<name[type][x];cout<<endl;
		cout<<(fst==1?s2:s1)<<" 手牌:";for(int x:h2)cout<<' '<<name[type][x];cout<<endl;
		Checkboth();
	}
	else
	{
		cout<<"SEED: "<<seed<<endl;
		cout<<s1<<" : "<<pointsA<<endl;
		cout<<s2<<" : "<<-pointsA<<endl;
		cout<<"Continue or not? 1. Continue 2. End"<<endl;	
		int useless=Askfornumber(1,2);
		if(useless==2)
		{
			if(pointsA>0) cout<<s1<<" has won."<<endl;
			else if(pointsA<0) cout<<s2<<" has won."<<endl;
			else cout<<s1<<" and "<<s2<<" has a tie."<<endl;
			system("pause");exit(0);
		}
		shuffle(tile,tile+136,myrand);
		cout<<"The game is now under construction. Please wait until the next version."<<endl;
		exit(0);
	}
	
}
vector<int> X;
void Test()
{
	X.clear();rep(j,13) X.pb(kokushi[j]);
	X.pb(0);cout<<acceptable(X)<<"=1"<<endl;
	X.clear();rep(j,13) X.pb(kokushi[j]);
	X.pb(1);cout<<acceptable(X)<<"=0"<<endl;
	X.clear();rep(i,7){X.pb(kokushi[i]);X.pb(kokushi[i]);}
	cout<<acceptable(X)<<"=1"<<endl;
	X.clear();rep(i,7){X.pb(kokushi[i]);X.pb(kokushi[i]+(i==0));}
	cout<<acceptable(X)<<"=0"<<endl;
	X.clear();X.pb(9);X.pb(9);X.pb(9);X.pb(17);X.pb(17);X.pb(17);for(int y=10;y<=16;++y)X.pb(y);
	for(int y=6;y<=19;++y) cout<<accept(X,y)<<"="<<(9<=y&&y<=17)<<endl;
	X.clear();rep(i,4){X.pb(27);X.pb(28);X.pb(29);}X.pb(30);X.pb(30);cout<<acceptable(X)<<"=0"<<endl;
}
int main()
{
//	Test();return 0;
	PreCompute();
	while(1)Game();
	return 0;
}
/* things to check
1.  int overflow or long long memory need
2.  recursion/array/binary search/dp/loop bounds
3.  precision
4.  special cases(n=1,bounds)
5.  delete debug statements
6.  initialize(especially multi-tests)
7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <=
8.  keep it simple and stupid
9.  do not delete, use // instead
10. operator priority
11. is there anything extra to output?
12. ...
*/

/* something to think about
1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
2. If contains "not", why not ?????? or few affect?
*/
原文