传送门 题目大意 让你构造一个有向图,使得从1到n有L条不同路径且长度分别是0~L-1. 分析 我们不难想到每一对相邻点之间连一条权值为0的边,之后二进制分解,将每一对点之间连一个权值为2^i的边,但是我们会发现这样在一些情况下还会剩下一些值不能覆盖.如果将剩下的值一一连边肯定会炸.于是我们还是利用二进制的思想,从最后一个点开始向前枚举,如果在这个点加上一条权值为之前不能构成的值中的最小值的边构成的数不会越界则加上这一条边.描述比较粗略,详见代码. 代码 #include<iostream>…
D - All Your Paths are Different Lengths 思路: 二进制构造 首先找到最大的t,使得2^t <= l 然后我们就能构造一种方法使得正好存在 0 到 2^t - 1 的路径 方法是:对于节点 i 到 i + 1,添加两条边,一条边权值是2^(i-1),一条边权值是0 对于剩下的2^t 到 l-1的路径,我们考虑倍增地求,每次添加一条节点 v 到 节点 n 的边,边的权值是 X ,新增的路径是X 到 X + 2^(v-1) - 1 第一次的X是 2^t,之后每…
题目传送门:https://arc102.contest.atcoder.jp/tasks/arc102_b 这道题有点毒瘤啊,罚时上天.. 显然若$ l=2^n $那么就可以直接二进制拆分,但是如果不满足这个要求就有点难办了... 但是我们可以按照数位dp的那个树形结构一样,把整个区间$ [0,l) $拆成多个满足二进制拆分的结构(在树上则表现为满二叉树),然后在树根对应的位置额外连边补足权值就行了.(数位dp不懂的可以在这里看:初探数位dp - QuartZ_Z - 博客园,其他细节可以看代…
原文链接https://www.cnblogs.com/zhouzhendong/p/ARC102D.html 题目传送门 - ARC102D 题意 给定 $L$,请你构造一个节点个数为 $n$ ,边数为 $m$ 的图,边带权,满足以下条件: 1. $n\leq 20$ 2. $m\leq 60$ 3. 如果有向边 $a\rightarrow b$ 存在,那么 $a<b$ . 4. 从 $1$ 走到 $n$ 总共有 $L$ 种不同的路径,这 $L$ 条路径的长度分别为 $0,1,\cdots ,…
All Your Paths are Different Lengths 题目链接:https://atcoder.jp/contests/arc102/tasks/arc102_b 题解: 构造题有技巧,如果题目中要求了20和60,那就从这里入手好了. 发现没法入手因为太平凡了.... 但是,他要求了每种值只出现了一次,容易联想到弄出来$log$个$2$的幂次. 诶?想到这里发现,$20$好像差不多就是$log$大小. 我们就放$20$个点,第$i$个点指向第$i + 1$个点两条边,$2^{…
Optimal Milking Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 13968 Accepted: 5044 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows.…
                                         Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 16461   Accepted: 5911 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow past…
Description FJ has moved his K ( <= K <= ) milking machines <= C <= ) cows. A ..K; the cow locations are named by ID numbers K+..K+C. Each milking point can <= M <= ) cows each day. Write a program to find an assignment for each cow to s…
POJ  2112 Optimal Milking (二分+最短路径+网络流) Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 10176   Accepted: 3698 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastu…
解题报告 农场有k个挤奶机和c头牛,每头牛到每一台挤奶机距离不一样,每台挤奶机每天最多挤m头牛的奶. 寻找一个方案,安排每头牛到某一挤奶机挤奶,使得c头牛须要走的全部路程中的最大路程的最小值. 要使每一头牛都去挤奶,那么建完模型就要推断是否满流. 因为是多源多点的网络,如果源点0,汇点n+1(n=k+c) 源点到每一头牛的容量为1,每一台机器到汇点的容量为m;用flody求出随意一头牛到随意一台机器的最短路; 对于取最大距离的最小值能够用二分来找. #include <iostream> #i…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 19456   Accepted: 6947 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
描述 FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs among the cows and the milking machines. The milking machine locations are named by ID num…
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarjan+polya Building Cubes with AtCoDeer 枚举 AtCoDeer and Election Report 贪心 Snuke's Coloring 思维题 Snuke's Coloring 2 线段树+单调栈 Make Them Even 贪心 1D Reversi 模…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 17811   Accepted: 6368 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
  Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 19347   Accepted: 6907 Case Time Limit: 1000MS issions: 19347   Accepted: 6907 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out…
C - Triangular Relationship 题解 枚举一个数%K的值然后统计另两个 代码 #include <bits/stdc++.h> #define enter putchar('\n') #define space putchar(' ') #define pii pair<int,int> #define fi first #define se second #define MAXN 200005 #define pb push_back //#define…
比赛传送门 T1 Triangular Relationship 分析之后发现有两种情况: 1. n为奇数,那么所有数都是k的倍数. 2. n为偶数,那么所有数都是k/2的倍数. 然后就可以愉快A题了. 代码: #include<bits/stdc++.h> #define N 200005 #define ll long long using namespace std; inline ll read(){ ll ans=0; char ch=getchar(); while(!isdigi…
题目链接:http://poj.org/problem?id=2112 Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs among the cows and the milking machines. The…
Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs among the cows and the milking machines. The milking machine locations are named…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 17297   Accepted: 6203 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重复. 分析: 思考什么样的三个数可以满足这样的要求,当然这三个数都是k的倍数的时候是可以满足的,还有就是这三个数在d对k取模之后都等于k/2也应该是可以的.直接枚举这样的数就可以了. #include <cstring> #include <cstdio> #include <a…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 20262   Accepted: 7230 Case Time Limit: 1000MS Description: FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) c…
Optimal Milking Time Limit:2000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2112 Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 20…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 15749   Accepted: 5617 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
题目链接:https://vjudge.net/problem/POJ-2112 Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 18555   Accepted: 6626 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow past…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 12482   Accepted: 4508 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
link C-Triangular Relationship 发现要么全部是\(K\)的倍数,要么全部是模\(K\)余\(K/2,(K=2n)\) #include<bits/stdc++.h> #define ll long long #define dbg1(x) cerr<<#x<<"="<<(x)<<" " #define dbg2(x) cerr<<#x<<"=&…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 15682   Accepted: 5597 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…
FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs among the cows and the milking machines. The milking machine locations are named by ID number…
Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 18083   Accepted: 6460 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) co…