What Is the biggest Smarter? (DP)

Source: Internet
Author: User

What Is the biggest Smarter? (DP)
Link to the question: Click to open the link DAG (directed acyclic graph). The longest path + print path graph creation is very simple. For two points a B, the condition from a to B is w [a]. S [B] attention is directed graph. Set dp [I] to the longest path length starting with I, dp [I] = max (dp [I], dp [j] + 1) enumeration j (j is a point connected to I)

#include #include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         
          #include 
          
           #include 
           #include 
            
             #define maxn 1010#define _ll __int64#define ll long long#define INF 0x3f3f3f3f#define Mod 1000000007#define pp pair
             
              #define ull unsigned long longusing namespace std;int p,w[maxn],s[maxn],dp[maxn];bool ma[maxn][maxn];void build(){memset(ma,0,sizeof(ma));for(int i=1;i
              
               s[j])ma[i][j]=1;else if(w[j]
               
                s[i])ma[j][i]=1;}}}int dfs(int x){int& ans=dp[x];if(ans>0) return ans;ans=1;for(int i=1;i
                
                 

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.