思路:判断黑或者白棋子的棋盒满了就输出,否则那就是平局
AC代码
#include <bits/stdc++.h>
using namespace std;
int n,m,c[5],x,cnt=1;//n,m输入,c表示黑棋和白棋的状态,cnt表示当前是谁提子
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
while(n--){
cin>>x;//输入x
c[cnt]+=x; //对应颜色的盒子加上当前提走的棋子
if(c[cnt]>m){ //判断棋盒有没有满
if(cnt==1){//1的状态是黑色提子
cout<<"White";
return 0;
}else{//反之0就是白色咯
cout<<"Black";
return 0;
}
}
cnt=!cnt;//!是取反的意思,只有0和1两种状态
}
cout<<"Draw";//平局
return 0;
}
//本蒟蒻的第一篇题解