hiho week 222 register

Ended

Participants:151

Verdict:Accepted
Score:100 / 100
Submitted:2018-10-01 20:17:26

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+50;
int n,mat[maxn][maxn];
int Up[maxn][maxn],Down[maxn][maxn],Left[maxn][maxn],Right[maxn][maxn];
int main(){
    while(~scanf("%d",&n)){
     memset(Up,0,sizeof(Up));
     memset(Down,0,sizeof(Down));
     memset(Left,0,sizeof(Left));
     memset(Right,0,sizeof(Right));
     for(int i=1;i<=n;i++){
        char s[n+1];
        scanf("%s",s+1);
        for(int j=1;j<=n;j++){
            mat[i][j] = s[j] - '0';
        }
     }
     for(int i=1;i<=n;i++){
       for(int j=1;j<=n;j++){
         if(mat[i][j]==1){
            Left[i][j] = Left[i][j-1] + 1;
            Up[i][j] = Up[i-1][j] + 1;
         }
         if(mat[i][n-j+1]==1){
            Right[i][n-j+1] = Right[i][n-j+2] + 1;
          }
          if(mat[n-i+1][j] == 1){
            Down[n-i+1][j] = Down[n-i+2][j] + 1;
          }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX