#include #include #include using namespace std; int main() { ifstream infile("barcode.in"); int N; int M; cin>>N>>M; string barcode[1001]; string a; bool changed = false; int z = 0; while (std::getline(infile, a)) { //cin>>a; barcode[z] = a; for(int j = 0; j < M; j++) { if((int)a[j] != (int)'.' && (int)a[j] != (int)'#' && z != N-1) { changed = true; break; } } if(z > 0) { if(barcode[z].compare(barcode[z-1]) != 0 && z != N-1) { changed = true; } } z++; } // for(int i = 0; i < N; i++) //{ // cin>>a; // barcode[i] = a; // for(int j = 0; j < M; j++) //{ // if((int)a[j] != (int)'.' && (int)a[j] != (int)'#' && i != N-1) // { // changed = true; // break; // } // } //if(i > 0) //{ // if(barcode[i].compare(barcode[i-1]) != 0 && i != N-1) // { // changed = true; // } // } //} if(changed == false) { if((int)barcode[N-1].length() != M) { changed = true; } else { for(int i = 0; i < M; i++) { if(((int)((char)barcode[N-1][i]))> 57 || (int)((char)barcode[N-1][i]) < 49) { changed = true; break; } } } } std::ofstream out("barcode.out"); //if(changed) //{ out << "NO"; //} //else // { // out << "BUY"; // } out.close(); return 0; }