-
Notifications
You must be signed in to change notification settings - Fork 2
/
bigbrn.cpp
42 lines (39 loc) · 855 Bytes
/
bigbrn.cpp
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
32
33
34
35
36
37
38
39
40
41
42
/*
ID:bigfish2
LANG:C++
TASK:bigbrn
*/
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
bool vis[1010][1010];
int dp[1010][1010];
int N,T,a,b;
int ans = 0;
int m(int a,int b, int c){
return min(min(a,b),c);
}
int main(){
freopen("bigbrn.in","r",stdin);
freopen("bigbrn.out","w",stdout);
cin >> N >> T;
for(int x = 0;x<T;x++){
cin >> a >> b;
a--;
b--;
vis[a][b] = true;
}
for(int x = 0;x<N;x++){
if(!vis[x][0]) dp[x][0] = 1;
if(!vis[0][x]) dp[0][x] = 1;
}
for(int x = 1;x<N;x++){
for(int y = 1;y<N;y++){
dp[y][x] = m(dp[y][x-1],dp[y-1][x-1],dp[y-1][x])+1;
if(vis[y][x]) dp[y][x] = 0;
}
}
for(int y = 0;y<N;y++) for(int x = 0;x<N;x++) if(ans<dp[y][x]) ans = dp[y][x];
cout << ans << endl;
}