Bzoj 3890 Usaco2015 Jan meeting time topology DP

Source: Internet
Author: User

Main topic

The Chinese test instructions on the question is too vague ...
Given a topological map, each has a forward edge of two weights, two people from 1 to N, respectively, walk these two weights. Ask if there is a right value so that all two people can walk through these weights to N.

Ideas

After reading the question, it was water. Maintaining two arrays Indicates whether the number from node 1th can reach J through the weight of I. Then do the topology map DP.

CODE
#define _crt_secure_no_warnings#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX#define Maxe 10010#define INF 0x3f3f3f3fusing namespace STD;intPoints,edges;intHead[max],total;int_next[maxe],aim[maxe];intLength[maxe],_length[maxe];inline voidADD (intXintYintLenint_len) {_next[++total] = head[x];    Aim[total] = y;    Length[total] = len;    _length[total] = _len; HEAD[X] = total;}int_in[max]; Queue<int>QBOOLF[max][maxe],g[max][maxe];BOOLV[max];intMain () {Cin>> points >> edges; for(intX,y,z,l,i =1; I <= edges; ++i) {scanf("%d%d%d%d", &x,&y,&z,&l);        ADD (x,y,z,l);    ++_in[y]; } for(inti =1; I <= points; ++i)if(!_in[i]) Q.push (i); f[1][0] = g[1][0] =true; while(!q.empty ()) {intx = Q.front (); Q.pop (); for(inti = head[x]; I i = _next[i]) { for(intj =0; J + Length[i] < Maxe; ++J) F[aim[i]][j + length[i]] |= f[x][j]; for(intj =0; J + _length[i] < Maxe; ++J) G[aim[i]][j + _length[i]] |= g[x][j];if(!--_in[aim[i]]) Q.push (Aim[i]); }    } for(inti =0; i < maxe; ++i)if(F[points][i]&g[points][i]) {cout<< i << Endl;return 0; }puts("Impossible");return 0;}

Bzoj 3890 Usaco2015 Jan meeting time topology DP

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.