#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<list>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define INS(X) inserter(x,x.begin())
int m,n;
#define X 10000 + 5
#define Y 10 + 5
#define Z 80 + 5
#define T 100000 + 100
char mat[X][Y][Z];
int main()
{
while( scanf("%d%d",&n,&m) != EOF) {
getchar();
int ans_x1,ans_x2;
int ans_y1,ans_y2;
int size_ans = 0;
for(int i = 0; i < n; i++) {
char str[Z * Y];
gets(str);
int L = strlen(str);
for(int j = 0, k = 0, size = 0; j < L; j++){
if(str[j] == ','){
mat[i][k++][size] = '\0';
size = 0;
}else if(j == L - 1){
mat[i][k][size++] = str[j];
mat[i][k++][size] = '\0';
size = 0;
}else
mat[i][k][size++] = str[j];
}
}
//对三维数组读取操作,以及使用集合判断字符串是否相同
for(int i = 0; i < m; i++){
for(int j = i + 1; j < m; j++){
map<string, int>ID_Card;
for(int k = 0; k < n; k++){
string str = "";
str += mat[k][i];//问题是这里什么意思?还加了两次
str += ",";
str += mat[k][j];
if(ID_Card.count(str)){
ans_x1 = ID_Card[str] + 1;
ans_x2 = k + 1;
ans_y1 = i + 1;
ans_y2 = j + 1;
size_ans = 1;
break;
}else{
ID_Card[str] = k;
}
}
if(size_ans) break;
}
if(size_ans) break;
}
if(size_ans > 0) {
printf("NO\n");
printf("%d %d\n",ans_x1, ans_x2);
printf("%d %d\n",ans_y1, ans_y2);
}else
printf("YES\n");
}
return 0;
}
UVA1592 Database(Map)
最新推荐文章于 2020-07-11 10:19:41 发布