-
Notifications
You must be signed in to change notification settings - Fork 2
/
数据库.cpp
61 lines (56 loc) · 1.03 KB
/
数据库.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<map>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int n, p;
map<string, int> m;
vector<string> v;
int ID(string s){
if(m.count(s)) return m[s];
v.push_back(s);
return m[s] = v.size() - 1;
}
int name[10000 + 10][10 + 10];
void find(){
for(int i = 0; i < p; i++){
for(int j = i+1; j<p; j++){
map<pair<int, int>, int> ss;
for(int k = 0; k<n;k++){
pair<int, int> l(name[k][i], name[k][j]);
if(ss.count(l) ==0){
ss[l] = k;
}else{
puts("NO");
cout<<ss[l] + 1<<" "<<k+1<<endl;
cout<<i+1<<" "<<j+1<<endl;
return;
}
}
}
}
puts("YES");
}
int main(){
while(cin>>n>>p){
getchar();
m.clear();
v.clear();
for(int i = 0; i < n; i++){
string s;
getline(cin, s);
// getchar();
s += ",";
int j = 0,start = 0, pos = 0;
while((pos = s.find(',', start))!=string::npos){
string r = s.substr(start, pos-start);
// cout<<r<<" "<<s<<endl;
name[i][j++] = ID(r);
pos++;
start =pos;
}
}
find();
}
return 0;
}