/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: tribn.cpp * Author: cteam081 * * Created on 22. října 2016, 11:01 */ #include #include #include #include //#define DEBUG using namespace std; string normalize(string input) { string result = ".............................."; for (char c : input) { result[c - 'A'] = c; } return result; } int main() { int lines; vectormap(26); vectornormal(26); while (cin >> lines) { // scan the map and calc their hashcodes for (int i = 0; i < lines; i++) { cin >> map[i]; normal[i] = normalize(map[i]); } // search for a good hashcode string good; if (normal[0] == normal[1]) { good = normal[0]; } else if (normal[0] == normal[2]) { good = normal[0]; } else { good = normal[1]; } #ifdef DEBUG cout << "good pattern: " << good << endl; #endif // search for a wrong hashcode int wrongRow; for (int i = 0; i < lines; i++) { if (normal[i] != good) { wrongRow = i; break; } } #ifdef DEBUG cout << "wrong row: " << (wrongRow + 1) << endl; #endif // search for incompatible character char missingColor = '-'; char extraColor = '-'; for (int i = 0; i < 26; i++) { if (normal[wrongRow][i] != good[i]) { if (good[i] != '.') { missingColor = 'A' + i; } else { extraColor = 'A' + i; } } } #ifdef DEBUG cout << "missing color: " << missingColor << endl; cout << "extra color: " << extraColor << endl; #endif if (extraColor != '-') { // we found somebody with an extra dress // search for his column int wrongCol; for (int i = 0; i < lines; i++) { if (map[wrongRow][i] == extraColor) { wrongCol = i; break; } } cout << (wrongRow + 1) << " " << (wrongCol + 1) << " " << missingColor << endl; } else { // we found two people with same dress // search column by column, which of them does not match the good hashcode // now check which dress is that. vectorpossibleWrongCols(2); vectorfound(26); char wrongColor; for(int i=0;i