代码拉取完成,页面将自动刷新
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
map<string,int> IDCache; // 将 串 映射到 ID
vector<string> StrCache; // 根据ID取string
const int MAX_I = 10005;
const int MAX_J = 12;
int ID(string x){
if(IDCache.count(x)){
return IDCache[x]; // 返回 字符串x 所对应的 ID(在StrCache里面的下标)
} else {
StrCache.push_back(x);
IDCache[x] = StrCache.size()-1;
return IDCache[x] ;
}
}
string Input(){
char ch;
string str;
int i=0;
while((ch=getchar()) && ch!=',' && ch!='\n'){
str += ch;
}
return str;
}
// int db[MAX_I][MAX_J];
int main(){
int n,m;
int db[4][4];
// freopen("./out.txt","w",stdout);
while(cin>>n>>m){
cin.ignore();
memset(db,-1,sizeof(db));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
string cur = Input();
// 现在得到目前的字符串
int id = ID(cur);
db[i][j] = id;
}
}
// 通过上述输入已经将string转换为int了
map<string,int > storeCache;
// 从俩列开始枚举
bool flag=true;
for(int i=0;i<m;i++){
if(!flag) break;
for(int j=i+1;j<m;j++){
if(!flag) break;
// 此时开始从列开始存map
for(int k=0;k<n;k++){
string cols = to_string(db[k][i])+","+to_string(db[k][j]);
auto iter = storeCache.find(cols);
if(/*map中包含该键值对*/ iter != storeCache.end()){
cout<<"NO\n";
cout<<(iter)->second+1<<" "<<k+1<<"\n"<<i+1<<" "<<j+1<<"\n";
flag = false;
break;
} else {
// 保存该键值对
storeCache[cols] = k;
}
}
}
storeCache.clear();
}
if(flag) cout<<"YES\n";
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。