求助,用c++getline写的,本地IDE能过但是提交后全部WA
查看原帖
求助,用c++getline写的,本地IDE能过但是提交后全部WA
629050
isItTrue楼主2021/12/14 17:54
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
int n=1,cnt=0;
char a[205][205] = { 0 };
int b[50005] = { 0 };
int main() {
	int p = 0;
	cin.getline(a[0], 205);
	n = strlen(a[0]);
	for (int i = 1; i < n; i++) {
		cin.getline(a[i], 205);
	}

		for (int j = 0; j < n; j++)//行
		{
			for (int k = 0; k < n; k++)//列
			{
				if (k == n - 1 && a[j][k] == a[j + 1][0])
					cnt++;
				else if (a[j][k] == a[j][k + 1])
					cnt++;
				else
				{
					b[p++] = cnt + 1;
					cnt = 0;
				}
			}
		}
		cout << n<<" ";
		if ((a[0][0] - '0')) cout << "0 ";
	for (int i = 0; i < p; i++)
	{
		cout << b[i] << " ";
	}
	cout << "\n";
	return 0;
}
2021/12/14 17:54
加载中...