Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

简单的写法

Posted by ACAccepted at 2019-03-16 15:25:45 on Problem 2965
In Reply To:我认为评测机有问题,一直wrong,重金求解答为什么错 Posted by:yangmin5416 at 2019-02-28 23:16:30
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

const int MAXN=5;
int map[MAXN][MAXN];
queue<pair<int,int> > Q;
int main()
{
	memset(map,0,sizeof(map));
	char c;
	for (int i=1;i<=4;i++)
		for (int j=1;j<=4;j++)
		{
			c=getchar();
			while (c!='-'&&c!='+')c=getchar();
			if (c=='+')
			{
				map[i][j]=1-map[i][j];
				for (int k=1;k<=4;k++)
				{
					map[i][k]=1-map[i][k];
					map[k][j]=1-map[k][j];
				}
			}
		}
	int ans=0;
	for (int i=1;i<=4;i++)
		for (int j=1;j<=4;j++)
			if (map[i][j]==1)
			{
				ans++;
				Q.push(make_pair(i,j));
			}
	printf("%d\n",ans);
	pair<int,int> top;
	while (!Q.empty())
	{
		top=Q.front();Q.pop();
		printf("%d %d\n",top.first,top.second);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator