Adding some more judges, here and there.
[and.git] / NEERC / database / database_gk_ok_cpp_map_nested.cpp
blob15819d45d27d8e03e0387a11f2eedd0481ce9317
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, map<string, int>*> outter;
39 for (int r1 = 0; r1 < n; r1++) {
40 map<string, int>* inner;
41 map<string, map<string, int>*>::iterator iter = outter.find(values[r1]->at(c1));
42 if (iter != outter.end()) {
43 inner = iter->second;
44 } else {
45 inner = new map<string, int>();
46 outter[values[r1]->at(c1)] = inner;
48 if (inner->find(values[r1]->at(c2)) != inner->end()) {
49 int r2 = inner->find(values[r1]->at(c2))->second;
51 out << "NO" << endl;
52 out << (r2 + 1) << " " << (r1 + 1) << endl;
53 out << (c1 + 1) << " " << (c2 + 1) << endl;
54 return 0;
55 } else {
56 (*inner)[values[r1]->at(c2)] = r1;
62 out << "YES" << endl;
64 in.close();
65 out.close();
67 return 0;