Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ll long long
- #include <bits/stdc++.h>
- using namespace std;
- const int OO = 1e9;
- const double EPS = 1e-9;
- map<pair<string,string>,int> mps[11][11];
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n,m;
- while(cin >> n >> m) {
- string x;
- getline(cin,x);
- //cout << "x is " << x << "\n";
- pair<int,int> ans_r = {-1,-1};
- pair<int,int> ans_c = {-1,-1};
- for(int r = 1; r <= n; r++) {
- string row = "";
- getline(cin,row);
- int idx = 0;
- string cols[11];
- for(int c = 1; c <= m; c++) {
- string col = "";
- for(; idx < row.size(); idx++) {
- if(row[idx] != ',')
- col += row[idx];
- else
- break;
- }
- idx++;
- //cout << col << "\n";
- cols[c] = col;
- /*if(mp.find(col) == mp.end()) {
- mp[col] = {r,c};
- }
- else {
- if(mp[col].first != r) {
- ans_r = {mp[col].first,r};
- ans_c = {mp[col].second,c};
- }
- }*/
- }
- for(int c1 = 1; c1 < m; c1++) {
- for(int c2 = c1+1; c2 <= m; c2++) {
- pair<string,string> curr = {cols[c1],cols[c2]};
- if(mps[c1][c2].find(curr) != mps[c1][c2].end()) {
- ans_r = {mps[c1][c2][curr],r};
- ans_c = {c1,c2};
- }
- else {
- mps[c1][c2][curr] = r;
- }
- }
- }
- }
- for(int i = 1; i < m; i++) {
- for(int j = i+1; j <= m; j++) {
- mps[i][j].clear();
- }
- }
- if(ans_r.first == -1) {
- cout << "YES\n";
- }
- else {
- cout << "NO\n";
- cout << ans_r.first << " " << ans_r.second << "\n";
- cout << ans_c.first << " " << ans_c.second << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement