Adding some more judges, here and there.
[and.git] / NEERC / database / database_gk_ok_cpp_map_concat.cpp
blob497104acdcb029e6b4ee7d603a37959e3e216349
1 #include <iostream>
2 #include <fstream>
3 #include <string>
4 #include <vector>
5 #include <map>
7 using namespace std;
9 int main() {
10 ifstream in; in.open("database.in");
11 ofstream out; out.open("database.out");
13 int n;
14 int m;
15 in >> n >> m;
16 in.ignore();
18 cout << n << endl;
19 vector<vector<string>*> values;
20 for (int i = 0; i < n; i++) {
21 char buffer[100];
22 vector<string>* row = new vector<string>();
24 for (int j = 0; j < m - 1; j++) {
25 in.getline(buffer, sizeof(buffer) / sizeof(char), ',');
26 row->push_back(buffer);
29 in.getline(buffer, sizeof(buffer) / sizeof(char), '\n');
30 row->push_back(buffer);
32 values.push_back(row);
35 for (int c1 = 0; c1 < m; c1++) {
36 cout << c1;
37 for (int c2 = c1 + 1; c2 < m; c2++) {
38 map<string, int> map;
39 for (int r1 = 0; r1 < n; r1++) {
40 string s1 = values[r1]->at(c1);
41 string s2 = values[r1]->at(c2);
42 string s = s1 + "," + s2;
43 //pair<string, string> p(s1, s2);
44 if (map.find(s) != map.end()) {
45 int r2 = map.find(s)->second;
47 out << "NO" << endl;
48 out << (r2 + 1) << " " << (r1 + 1) << endl;
49 out << (c1 + 1) << " " << (c2 + 1) << endl;
50 return 0;
52 map[s] = r1;
58 out << "YES" << endl;
60 in.close();
61 out.close();
63 return 0;