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

Ended

Participants:189

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-17 12:54:04

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 <cstdio>
#include <cstdlib>
#include <string.h> 
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    int n,m;
    cin>>n>>m;
    int A[n][m];
    string hehe;
    int dp[n][m];//i,j
    for(int i=0;i<n;i++){
        cin>>hehe;
        for(int j=0;j<m;j++){
            A[i][j]=hehe[j]-'0';
            dp[i][j]=1;
            //printf("%d\n",A[i][j]);
        }
    }
    int ans=1;              
    //memset(dp,1,sizeof dp);
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(!(A[i][j]!=A[i][j-1]&&A[i][j]!=A[i-1][j]))continue;
            int topp=dp[i-1][j];
            int left=dp[i][j-1];
            int tmp=min(topp,left);
            if(A[i-tmp][j-tmp]!=A[i-tmp][j-tmp+1]&&A[i-tmp][j-tmp]!=A[i-tmp+1][j-tmp])
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX