#include #include #include using namespace std; string a0[7] = { "+---+", "| |", "| |", "+ +", "| |", "| |", "+---+" }; string a1[7] = { " +", " |", " |", " +", " |", " |", " +" }; string a2[7] = { "+---+", " |", " |", "+---+", "| ", "| ", "+---+" }; string a3[7] = { "+---+", " |", " |", "+---+", " |", " |", "+---+" }; string a4[7] = { "+ +", "| |", "| |", "+---+", " |", " |", " +" }; string a5[7] = { "+---+", "| ", "| ", "+---+", " |", " |", "+---+" }; string a6[7] = { "+---+", "| ", "| ", "+---+", "| |", "| |", "+---+" }; string a7[7] = { "+---+", " |", " |", " +", " |", " |", " +" }; string a8[7] = { "+---+", "| |", "| |", "+---+", "| |", "| |", "+---+" }; string a9[7] = { "+---+", "| |", "| |", "+---+", " |", " |", "+---+" }; string dl[7] = { " ", " ", "o", " ", "o", " ", " " }; string a[10][7]; string b[4][7]; string n[7]; string d[7]; void make(string s) { int c[4]; c[0] = s[0] - 48; c[1] = s[1] - 48; c[2] = s[3] - 48; c[3] = s[4] - 48; { int j; for(int i = 0; i<7; i++) { stringstream ss; j = 0; ss << a[c[j]][i]; ss << " "; j++; ss << a[c[j]][i]; ss << " "; j++; ss << dl[i]; ss << " "; ss << a[c[j]][i]; ss << " "; j++; ss << a[c[j]][i]; getline(ss, d[i]); } } } bool test() { for(int i = 0; i<7; i++) { for(int j = 0; j<29; j++) { if(n[i][j] != '.' && n[i][j] != d[i][j]) { return false; } } } return true; } int main() { for(int i = 0; i<7; i++) { a[0][i] = a0[i]; a[1][i] = a1[i]; a[2][i] = a2[i]; a[3][i] = a3[i]; a[4][i] = a4[i]; a[5][i] = a5[i]; a[6][i] = a6[i]; a[7][i] = a7[i]; a[8][i] = a8[i]; a[9][i] = a9[i]; } string s; int rowindex = 0; getline(cin, s); while(s != "end") { rowindex = 0; n[rowindex] = s; rowindex++; for(int i = 0; i < 6; i++) { getline(cin, s); n[rowindex] = s; rowindex++; } getline(cin, s); getline(cin, s); /* for(int i = 0; i < 7; i++) { cout << n[i] << endl; } */ string tim; string solution = ""; bool isFirst = false; for(int i=0; i< 24; i++) { for(int j=0; j< 60; j++) { tim = ""; tim += (char)(i/10)+48; tim += (char)(i%10)+48; tim += ':'; tim += (char)(j/10)+48; tim += (char)(j%10)+48; // cout << ">>> " << tim << endl; make(tim); if (test()) { // cout << tim << endl; if (!isFirst) { isFirst = true; solution = tim; } else { solution = "ambiguous"; } } } } cout << solution << endl; getline(cin, s); } cout << "end" << endl; return 0; }