F. Double Knapsack 题目连接: http://www.codeforces.com/contest/618/problem/F Description You are given two multisets A and B. Each multiset has exactly n integers each between 1 and n inclusive. Multisets may contain multiple copies of the same number. Y…
B. Guess the Permutation 题目连接: http://www.codeforces.com/contest/618/problem/B Description Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i,…
A. Slime Combining 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2768 Description Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initi…
E. Robot Arm 题目连接: http://www.codeforces.com/contest/618/problem/E Description Roger is a robot. He has an arm that is a series of n segments connected to each other. The endpoints of the i-th segment are initially located at points (i - 1, 0) and (i…
现在水平真的不够.只能够做做水题 A. Slime Combining 题意:就是给n个1给你.两个相同的数可以合并成一个数,比如说有两个相同的v,合并后的值就是v+1 思路:直接模拟栈 #include<iostream> #include<algorithm> #include<stack> using namespace std; ]; int main() { int n; while(cin >> n){ stack<int>p; p.…
直接O(n*m)的dp也可以直接跑过. 因为上最多跑到m就终止了,因为前缀sum[i]取余数,i = 0,1,2,3...,m,有m+1个余数,m的余数只有m种必然有两个相同. #include<bits/stdc++.h> using namespace std; ; int cnt[maxn]; bool dp[maxn][maxn]; #define Y { puts("YES"); return 0; } int main() { //freopen("i…
题目链接:https://codeforces.com/problemset/problem/1365/E 题意 有 $n$ 个元素,定义大小为 $k$ 的集合值为 $\sum2^i$,其中,若集合内至少有 $max(1, k - 2)$ 个数二进制下第 $i$ 位为 $1$,则第 $i$ 位有效,求一个集合可以得到的最大值. 题解 每个 $k > 3$ 的集合的值一定小于等于 $k = 3$ 的子集合的值,所以枚举大小 $1 \sim 3$ 的集合即可. 证明 如果原集合中某一位有效,则至少在…
题解: 坐标(0,m)的话,闭区间,可能一共有多少曼哈顿距离? 2m 但是给一个n,可能存在n(n+1)/2个曼哈顿距离 所以可以用抽屉原理了 当n比抽屉的数量大,直接输出yes 不用计算 那...NO呢 那就暴力 n^2 这个n肯定不会太大 队友code--.. #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algori…
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/problem/A 题目给出的条件是 距离为曼哈顿距离,而曼哈顿距离等价于步长. 由题目的一半条件,可以得到步长和为AB步长,各自步长为AB步长的一半. 所以显然可以推出: \[1.如果和为奇数则,不存在\\ 2.如果都为偶数,显然只需要取步长一半即可\\ \] //原始代码 #include<bi…
1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组,每行最多可交换1次,列最多可交换两列,问最终是否可以变换到每行都是1~m. 2.总结:暴力即可. #include<bits/stdc++.h> #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a,b) for (int i=a;i&l…