#include <bits/stdc++.h>
using namespace std;
#define MST(a,b) memset(a,b,sizeof(a));
#define CLR(a) MST(a,0);
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
const int maxrow = 10000 + 10;
const int maxcol = 10 + 5;
int r = 0,c = 0, t = 1;
int arr[maxrow][maxcol];
map<string,int> mp;
map<pair<int,int>, int> mp2;
int main(int argc, char const *argv[])
{
string temp;
string x;
while(cin >> r >> c ){
int col = 0; t = 1; CLR(arr); mp.clear(); x.clear(); mp2.clear();
getchar();
_for(i,0,r){
col = 0;
getline(cin,temp);
int len = temp.length();
_for(j,0,len){
if(temp[j] != ',') x += temp[j];
if(temp[j] == ',' || j == len-1){
if(mp.count(x) == 0) mp[x] = t++;
arr[i][col] = mp[x];
col++;
x.clear();
}
temp.clear();
}
}
_for(i,0,c-1){
for(int j = i+1; j < c; j++){
_for(k,0,r){
int x1 = arr[k][i], x2 = arr[k][j];
if(mp2.count(make_pair(x1,x2))){
//第二次匹配,存在输出
cout << "NO" << endl;
cout << mp2[make_pair(x1,x2)] << " " << k+1 << endl;
cout << i+1 << " " << j+1 << endl;
goto kcl;
}else{
mp2[make_pair(x1,x2)] = k + 1;
}
}
mp2.clear();
}
}
cout << "YES" << endl;
kcl:{}
}
return 0;
}
测试数据:
3 3
How to compete in ACM ICPC,Peter,peter@neerc.ifmo.ru
How to win ACM ICPC,Michael,michael@neerc.ifmo.ru
Notes from ACM ICPC champion,Michael,michael@neerc.ifmo.ru
2 3
1,Peter,peter@neerc.ifmo.ru
2,Michael,michael@neerc.ifmo.