Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int T = 12;
- int mat[T][T];
- int ri[T][T];
- int le[T][T];
- bool po[T][T];
- int n,m,p;
- int main() {
- cin >> n >> m >> p;
- while(n or m or p) {
- p--;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- cin >> mat[i][j];
- if(mat[i][j]) po[i][j] = 1;
- else po[i][j] = 0;
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 1; j < m; j++) {
- if(mat[i][j]) le[i][j] = mat[i][j];
- else le[i][j] = le[i][j-1];
- }
- }
- for(int i = 0; i < n; i++){
- for(int j = m-1; j >= 0; j--) {
- if(mat[i][j]) ri[i][j] = mat[i][j];
- else ri[i][j] = ri[i][j+1];
- }
- }
- int i = 0;
- bool flag = 0;
- while(i < n) {
- if(ri[i][p] > le[i][p]) {
- int x = ri[i][p] - le[i][p];
- int z = p-x;
- for(; p >= z and !flag; p--) {
- if(p < 0 or po[i][p]) { cout << "BOOM " << i+1 << " " << p+1 << endl; flag = 1; }
- }
- p++;
- }
- else if(le[i][p] > ri[i][p]) {
- int x = le[i][p] - ri[i][p];
- int z = p+x;
- for(; p <= z and !flag; p++) {
- if(p >= m or po[i][p]) { cout << "BOOM " << i+1 << " " << p+1 << endl; flag = 1; }
- }
- p--;
- }
- i++;
- }
- if(!flag) cout << "OUT " << p+1 << endl;
- cin >> n >> m >> p;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement