Untitled
unknown
plain_text
a year ago
3.5 kB
4
Indexable
//#include <iostream> //using namespace std; //int A[100][100] = {0}, mark[100][100] = {0}; //int t, n, m; //int tc = 0; //int Max, Min; //int Qx[999999], Qy[999999]; //int frontX, frontY, rearX, rearY, xmax, ymax; //int flag = 0, f; //int dx[4] = {0, 0, -1, 1}; //int dy[4] = {1, -1, 0, 0}; //int x, y, tx, ty; //int c, d; // //int isEmptyX() { // if (rearX == frontX) return 1; // return 0; //} //int isFullX() { // if (rearX == 9999) return 1; // return 0; //} // //void createQX() { // frontX = -1; // rearX = -1; //} // //void enQueueX(int x) { // if (!isFullX()) { // rearX++; // Qx[rearX] = x; // } //} // //int deQueueX() { // if (!isEmptyX()) { // frontX++; // return Qx[frontX]; // } //} // //int isEmptyY() { // if (rearY == frontY) return 1; // return 0; //} //int isFullY() { // if (rearY == 9999) return 1; // return 0; //} // //void createQY() { // frontY = -1; // rearY = -1; //} // //void enQueueY(int x) { // if (!isFullY()) { // rearY++; // Qy[rearY] = x; // } //} // //int deQueueY() { // if (!isEmptyY()) { // frontY++; // return Qy[frontY]; // } //} //void resetMark() { // for (int i = 0; i < n; i++) { // for (int j = 0; j < m; j++) mark[i][j] = 0; // } //} // //void bfs1(int x1, int y1, int h) { // createQX(); // createQY(); // enQueueX(x1); // enQueueY(y1); // mark[x1][y1] = 1; // c++; // while(!isEmptyX()) { // x = deQueueX(); // y = deQueueY(); // for (int i = 0; i < 4; i++) { // tx = x + dx[i]; // ty = y + dy[i]; // if (tx > -1 && tx < n && ty > -1 && ty < m && mark[tx][ty] == 0 && A[tx][ty] <= h) { // enQueueX(tx); // enQueueY(ty); // mark[tx][ty] = 1; // c++; // } // } // } //} // //void bfs(int h) { // createQX(); // createQY(); // enQueueX(xmax); // enQueueY(ymax); // mark[xmax][ymax] = 1; // d++; // while(!isEmptyX()) { // x = deQueueX(); // y = deQueueY(); // for (int i = 0; i < 4; i++) { // tx = x + dx[i]; // ty = y + dy[i]; // if (tx > -1 && tx < n && ty > -1 && ty < m && mark[tx][ty] == 0) { // enQueueX(tx); // enQueueY(ty); // mark[tx][ty] = 1; // d++; // } // } // } //} //int main() { // freopen("input.txt", "r", stdin); // n = 1; // m = 1; // while(n != 0 && m != 0) { // tc++; // Max = -1; // Min = 1000; // cin >> n >> m; // for (int i = 0; i < n; i++) { // for (int j = 0; j < m; j++) { // cin >> A[i][j]; // if (Min > A[i][j] && (i == 0 || i == n-1 || j == 0 || j == m-1)) Min = A[i][j]; // if (Max < A[i][j]) { // Max = A[i][j]; // xmax = i; // ymax = j; // } // } // } // flag = 0; // for (int i = Min; i < Max; i++) { // resetMark(); // c = 0; // d = 0; // for (int j = 0; j < m; j++) { // if (mark[0][j] == 0 && A[0][j] <= i){ // bfs1(0, j ,i); // } // if (mark[n-1][j] == 0 && A[n-1][j] <= i) { // bfs1(n-1, j, i); // } // } // for (int j = 0; j < n; j++) { // if (mark[j][0] == 0 && A[j][0] <= i){ // bfs1(j, 0 ,i); // } // if (mark[j][m-1] == 0 && A[j][m-1] <= i) { // bfs1(j, m-1, i); // } // } // bfs(i); // if (n*m - c > d) { // flag = 1; // f = i; // break; // } // } // cout << "Case " << tc << ": "; // if (flag == 0) cout << "Island never splits." << endl; // else cout << "Island splits when ocean rises " << f <<" feet." << endl; // } // return 0; //}
Editor is loading...
Leave a Comment