U E D R , A S I H C RSS

1R/2016_09_27 (rev. 1.1)

1R/2016_09_27



1. 오늘의 문제

2. 참가자

  • 15이원준

3. 코드

3.1. 15이원준

#include<iostream>

using namespace std;

int arr[502][502] = { 0, };
int dp[502][502] = { 0, };
int ans = 0;
int N;
int search(int x, int y){
  if(dp[x][y] || x <= 0|| y <= 0 || x > N || y > N){
    return dp[x][y];
  }
  int now = 0;

  if(arr[x][y] < arr[x+1][y]){
    dp[x][y] = max(search(x + 1, y) + 1 ,dp[x][y]);
  }
  if(arr[x][y] < arr[x-1][y]){
    dp[x][y] = max(search(x - 1, y) + 1 ,dp[x][y]);
  }
  if(arr[x][y] < arr[x][y+1]){
    dp[x][y] = max(search(x, y + 1) + 1 ,dp[x][y]);
  }
  if(arr[x][y] < arr[x][y-1]){
    dp[x][y] = max(search(x, y - 1) + 1 ,dp[x][y]);
  }
  if(dp[x][y] > ans){
    ans = dp[x][y];
  }
  return dp[x][y];
}
int main(){
  cin>> N;
  for(int i = 1; i<=N; i++){
    for(int j = 1; j <= N; j++){
      int tmp;
      scanf("%d", &tmp);
      arr[i][j] = tmp;
    }
  }
  for(int i = 1; i<=N; i++){
    for(int j = 1; j <= N; j++){
      if(!dp[i][j]){
        search(i,j);
      }
      //cout<< dp[i][j] << " ";
    }
    //cout<<endl;
  }
  cout<< ans + 1 <<endl;
}

3.2. 박인서


3.3. 곽정흠


4. 아이디어

4.1. 15이원준

  • 걍 dfs했습니다.
  • 약간의 dp를 첨가했습니다.

4.2. 박인서


4.3. 곽정흠

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:08
Processing time 0.0392 sec