大佬们来看看,结果和下载的样例一样,为啥全都WA了
查看原帖
大佬们来看看,结果和下载的样例一样,为啥全都WA了
357761
hhhdddfff楼主2020/7/24 15:24
#include<iostream>
#include<string>

using namespace std;

int before,row,after,n,num,rest=0,sum=0,flag=0;

int main()
{
	cin >> n;
	while (sum <= n*n)
	{
		cin >> num;
		sum += num;
		rest += num;
		if (rest >= n)
		{
			before = rest%n;
			row = rest / n;
			after = n - rest + num;
			if (flag == 0)
			{
				string str1(after, '0');
				cout << str1 << endl;
				for (int i = 1; i < n; i++)
				{
					string str(n, '0');
				}
				string str2(before, '0');
				cout << str2;
			}
			else if (flag == 1)
			{
				string str1(after, '1');
				cout << str1 << endl;
				for (int i = 1; i < n; i++)
				{
					string str(n, '1');
				}
				string str2(before, '1');
				cout << str2;
			}
			rest = before;
			flag = 1 - flag;
		}
		else
		{
			if (flag == 0)
			{
				string str(num, '0');
				cout << str;
			}
			else if (flag == 1)
			{
				string str(num, '1');
				cout << str;
			}
			flag = 1 - flag;
		}
	}
	return 0;
}
2020/7/24 15:24
加载中...