codevs 3058 寻找sb5

3058 寻找sb5

题目描述 Description

sb被关在迷宫里了,小sh很着急,要去找她。输入一个数n,接着输入一个n*n的数字方阵,其中一个数字与其他不同,那就是sb的位置。输出她的位置,好让小s去找。

输入描述 Input Description

第一行输入n

接着输入一个n*n的方阵,注意,数字之间没有空格,方阵中的每个数小于10

输出描述 Output Description

先输出行,再输出列

样例输入 Sample Input

4

1111

1121

1111

1111

样例输出 Sample Output

数据范围及提示 Data Size & Hint

n<=10000

/*
大师级水题
*/
#include<cstdio>
#include<iostream>
using namespace std;
int n;
char b[10001];
struct node
{
	int s,x,y;
}a[10001];
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		cin>>b;
		for(j=1;j<=n;j++)
		{
			int x=b[j-1]-'0';
			a[x].s++;
			a[x].x=i;
			a[x].y=j;
		}
	}
	for(i=0;i<10;i++)
	  if(a[i].s==1)
	  {
	  	printf("%d\n%d",a[i].x,a[i].y);
	  	return 0;
	  }
}

  

posted @ 2016-09-03 10:33  一叶落尽天下秋  阅读(142)  评论(0编辑  收藏  举报