[Pressure DP] POJ1185 Artillery Positions

Source: Internet
Author: User

Chinese question test instructions no longer repeat

For this "P" in the middle, we just need to consider the previous

It becomes just a matter of consideration:

That is, two lines before the pressure.

Specifically similar to HDOJ's 4539: see Hdoj 4539

It's just a different judgment of coexistence.

1 //#include <bits/stdc++.h>2#include <cstdio>3#include <cstring>4#include <iostream>5#include <algorithm>6 using namespacestd;7typedefLong LongLL;8 9 intdp[2][1050][1050], mp[ the][ the];Ten intpos[1050], D; One intMain () A { -     intD=0; -      for(intI=0;i< (1<<Ten); i++) the         if(! (i& (i<<2)) &&! (i& (i<<1))) -Pos[d++]=i;//preprocess a row of eligible -     intN, M; -      while(~SCANF ("%d%d", &n, &m)) +     { -         intans=0; +Memset (MP,0,sizeof(MP)); A          for(intI=1; i<=n;i++) at              for(intj=0; j<m;j++) -             { -                 CharC; -Cin>>C; -Mp[i][j]= (c=='P'); -             } inMemset (DP,0,sizeof(DP)); -          for(intI=1; i<=n;i++)//Enumerate n rows to              for(intj=0; J<d && pos[j]< (1&LT;&LT;M); j + +) +             { -                 intsum=0; the                  for(intk=0; k<m;k++)//for the current (i,k position) whether the row (in front of the K-grid) satisfies *                     if(pos[j]&1<<k) $sum+=Mp[i][k];Panax Notoginseng                  for(intk=0; K<d && pos[k]< (1&LT;&LT;M); k++)//enumerate the state of a i-1 row to see if it can coexist with line I -                     if(! (pos[j]&Pos[k])) the                     { +                         inttmp=0; A                          for(intL=0; L<d && pos[l]< (1&LT;&LT;M); l++)//enumerate the state of i-2 rows to see if they can coexist with line I, line i-1 the                             if(! (pos[j]&Pos[l])) +Tmp=max (TMP, dp[1-i&1][k][l]); -dp[i&1][j][k]=tmp+sum; $Ans=max (ans, dp[i&1][j][k]); $                     } -             } -printf"%d\n", ans); the     } -     return 0;Wuyi}
POJ 1185

[Pressure DP] POJ1185 Artillery Positions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.