Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define INF 1e9
- #define pb push_back
- #define mp make_pair
- #define nl '\n'
- typedef long long ll;
- typedef vector<int> vi;
- typedef pair<int,int> ii;
- typedef vector<ii> vii;
- int grid[105][105];
- int sol[105][105];
- int canPlace(int x,int y){
- if(grid[x][y]==1){
- return 1;
- }
- else return 0;
- }
- int search(int x,int y,int k){
- int count=0,up=0,down=0,left=0,right=0;
- for(int i=0;i<k;i++){
- cout << "loop #" << i << nl;
- cout << "checking " << x+1 << " " << y+i+1 << " is " << grid[x][y+i] << nl;
- if(grid[x][y+i]==1){
- up++;
- }
- cout << "up is now " << up << nl;
- cout << "checking " << x+1 << " " << y-i+1 << " " << grid[x][y-i] << nl;
- if(grid[x][y-i]==1){
- down++;
- }
- cout << "down is now " << down << nl;
- cout << "checking " << x+i+1<< " " << y+1 << " " << grid[x+i][y] << nl;
- if(grid[x+i][y]==1){
- right++;
- }
- cout << "right is now " << right << nl;
- cout << "checking " << x-i+1 << " " << y+1 << " " << grid[x-i][y] << nl;
- if(grid[x-i][y]==1){
- left++;
- }
- cout << "left is now " << left << nl;
- }
- if(up==k) count++;
- if(down==k) count++;
- if(left==k) count++;
- if(right==k) count++;
- cout << count << nl;
- return count;
- }
- int main(){
- ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- int n,k,x=1,y=1,max=0;
- char tmp;
- cin >> n >> k;
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- cin >> tmp;
- if(tmp=='#') grid[i][j]=-1;
- else grid[i][j]=1;
- }
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- if(grid[i][j]==0) continue;
- sol[i][j]=search(i,j,k);
- }
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- if(sol[i][j]>max){
- x=i+1;
- y=j+1;
- max=sol[i][j];
- }
- }
- }
- cout << x << " " << y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement