Hu before the opening title collection

Upcoming competition to write a title can not write much better to look at the mouth Hu title

After just tried mouth

 

P4042 [AHOI2014 / JSOI2014] Knight game

After a start to think of all thrown into the queue SPFA metaphysics relaxation, T think it will be like a long time do otherwise, is actually a solution to a problem SPFA look, feel that we can practice hand writing write the results found that violent sound and writing, even if you do not need to add open O² register in order to lead

#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define For(i, x, y) for(int i=x;i<=y;i++)
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x)
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x)
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
LL read(){LL x = 0,f = 1;char c = getchar();while (c<'0' || c>'9'){if (c == '-') f = -1;c = getchar();}
while (c >= '0'&&c <= '9'){x = x * 10 + c - '0';c = getchar();}return x*f;}
const double PI = acos(-1.0);
const double eps = 1e-9;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int N,M,K;
vector<int>P[maxn],Q[maxn];
LL a[maxn],b[maxn];
LL dp[maxn];
bool vis[maxn];
inline void SPFA(){
    queue<int>Qu;
    for(int i = 1; i <= N ; i ++){
        vis[i] = 1;
        Qu.push(i);
    }
    while(!Qu.empty()){
        int u = Qu.front(); Qu.pop();
        vis[u] = 0;
        LL sum = a[u];
        for(register int i = 0; i < P[u].size(); i ++){
            int v = P[u][i];
            sum += dp[v];
        }
        if(sum >= dp[u]) continue;
        dp[u] = sum;
        for(register int i = 0 ; i < Q[u].size(); i ++){
            int v = Q[u][i];
            if(!vis[v]){
                Qu.push(v);
                vis[v] = 1;
            }
        }
    }
}
int main(){
    Sca(N);
    for(int i = 1; i <= N ; i ++){
        a[i] = read(); dp[i] = read();
        int K = read();
        while(K--){
            int x = read();
            P[i].pb(x); Q[x].pb(i);
        }
    }
    SPFA();
    Prl(dp[1]);
    return 0;
}
View Code

 

Small sensor P2189 Z

At first glance I thought it was a great title operations, a closer look at a range of only 5 q

Then each sensor interrogation room without first of all with disjoint-set connected together, followed by each point and asked whether there is an edge disjoint-set initial point is connected to.

 

P2416 puffs

No mouth Hu looked out solution to a problem

The whole point of using biuret FIG tarjan side chain, and then find the tree is> = 1 to

Guess you like

Origin www.cnblogs.com/Hugh-Locke/p/11647339.html