House Man Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3605    Accepted Submission(s): 1517 Problem Description In Fuzhou, there is a crazy super man. He can’t fly, but he could jump from hou…
[Nowcoder71E]组一组(差分约束,最短路) 题面 Nowcoder 题解 看到二进制显然就直接拆位,那么区间的按位或和按位与转成前缀和之后,可以写成两个前缀和的值的差的大小关系,那么直接差分约束就好了. 注意几个细节,首先相等是要两侧都要连边,不要直连了一侧:然后这题卡常,所以对于区间内全是一的情况,处理出哪些位置确定是一,然后求个前缀和,直接从\(0\)连过去,这样子可以优化大量时间. #include<iostream> #include<cstdio> #inclu…
题目链接:https://cn.vjudge.net/contest/209473#problem/B 题目大意:对于n个数字,给出sum[j]-sum[i](sum表示前缀和)的符号(正负零),求一组n个数的的可行解(n个数都在-10——10之间)[保证一定有解] 解题思路: 第一反应!差分约束! 差分约束是用来求解不等式组的合理解的,用在此题上刚好,把sum[i]-sum[j]>0转化为sum[i]-sum[j]>=-1,小于零同理.把sum[i]-sum[j]==0转化为sum[i]-s…
Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 20067   Accepted: 5293 Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large b…
World Exhibition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2162    Accepted Submission(s): 1063 Problem Description Nowadays, many people want to go to Shanghai to visit the World Exhibiti…
题意: 给一个n*m矩阵,每个格子上有一个数字a[i][j],给定L和U,问:是否有这样两个序列{a1...an}和{b1...bn},满足 L<=a[i][j]*ai/bj<=U .若存在输出yes,否则no. 思路: 能够得到的是一堆不等式,那么可以用最短路来解决差分约束系统.但是a[i][j]*ai/bj<=U是除的,得提前变成减的才行.可以用对数log来解决,先不管a[i][j],logai-logbj<=U不就行了?可以得到: (1)logai - logbj<=U…
这是通化邀请赛的题,当时比赛的时候还完全没想法呢,看来这几个月的训练还是有效果的... 题意要求(1) |ai| < T for all i   (2) (vi, vj) in E <=> |ai - aj| >= T.由于(1)条件的存在,所以(2)条件能成立当且仅当ai和aj一正一负.由此可见,图中某条路上的元素正负值分别为正->负->正->负...显然当图中存在奇环的时候是无解的.判断奇环用二分染色,color[i]=0表示假设i节点未被染色,1表示假设i节…
King Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14791   Accepted: 5226 Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound kin…
Layout Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15349   Accepted: 7379 Description Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along…
题意: 有N头牛, 有以下关系: (1)A牛与B牛相距不能大于k (2)A牛与B牛相距不能小于k (3)第i+1头牛必须在第i头牛前面 给出若干对关系(1),(2) 求出第N头牛与第一头牛的最长可能距离, 若无解输出-1, 若无限长输出-2 分析: 3个关系对应的 <= 式子是: dis[b] - dis[a] <= d(1) dis[a] - dis[b] <= -d(2) dis[i] - dis[i+1] <= -1(2) 目标式:dis[N] - dis[1] <=…