#include #include #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(int bg, int cnt) { for(int i = 0; i<7; i++) { for(int j = bg; j s0; set s1; set s2; set s3; for(int j=0; j< 3; j++) { tim = ""; tim += (char)(j%10)+48; tim += '0'; tim += ':'; tim += '0'; tim += '0'; // cout << ">>> " << tim << endl; make(tim); if (test(0,5)) { s0.insert(j); } } for(int j=0; j< 10; j++) { tim = ""; tim += '0'; tim += (char)(j%10)+48; tim += ':'; tim += '0'; tim += '0'; // cout << ">>> " << tim << endl; make(tim); if (test(7,5)) { s1.insert(j); } } for(int j=0; j< 6; j++) { tim = ""; tim += '0'; tim += '0'; tim += ':'; tim += (char)(j%10)+48; tim += '0'; // cout << ">>> " << tim << endl; make(tim); if (test(17,5)) { s2.insert(j); } } for(int j=0; j< 10; j++) { tim = ""; tim += '0'; tim += '0'; tim += ':'; tim += '0'; tim += (char)(j%10)+48; // cout << ">>> " << tim << endl; make(tim); if (test(24,5)) { s3.insert(j); } } if (s2.size() > 1 || s3.size() > 1) { isFalsch = true; } string hours; set::iterator it0; set::iterator it1; int richtigCount = 0; if(!isFalsch) { it0 = s0.begin(); while(it0!=s0.end()) { it1 = s1.begin(); while(it1!=s1.end()) { //cout << (10 * (*it0) + *it1) << endl; if (10 * (*it0) + *it1 < 24) { richtigCount++; hours = ""; hours += (*it0)+48; hours += (*it1)+48; } it1++; } it0++; } } if(richtigCount > 1) { isFalsch = true; } it0 = s2.begin(); it1 = s3.begin(); hours += ':'; hours += (*it0)+48; hours += (*it1)+48; if(!isFalsch) { solution = hours; } else { solution = "ambiguous"; } /* 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(0,5)) { // cout << tim << endl; if (!isFirst) { isFirst = true; solution = tim; } else { solution = "ambiguous"; } } } } */ cout << solution << endl; getline(cin, s); } cout << "end" << endl; return 0; }