[Offer收割]编程练习赛40 register

Ended

Participants:189

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-17 13:03:56

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<iostream>
#include<vector>
using namespace std;
int check(vector<vector<int>>& t, int i, int j){
    int flag = 0;
    int row1 = t[i][j] + t[i][j+1] + t[i][j+2];
    int row2 = t[i+1][j] + t[i+1][j+1] + t[i+1][j+2];
    int row3 = t[i+2][j] + t[i+2][j+1] + t[i+2][j+2];
    int col1 = t[i][j] + t[i+1][j] + t[i+2][j];
    int col2 = t[i][j+1] + t[i+1][j+1] + t[i+2][j+1];
    int col3 = t[i][j+2] + t[i+1][j+2] + t[i+2][j+2];
    int cr1 = t[i][j] + t[i+1][j+1] + t[i+2][j+2];
    int cr2 = t[i][j+2] + t[i+1][j+1] + t[i+2][j];
    if ((row1 == row2) && (row2 == row3)
        && (col1 == col2) && (col2 == col3) && (cr1 == cr2)
        && (col1 == row1) && (row1 == cr1)) {
        flag = 1;
    }
    return flag;
}
int main(){
    int N, M, cnt = 0;
    cin>>N>>M;
    vector<vector<int> > m(N, vector<int>(M));
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin>>m[i][j];
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX