地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and…
从任意点出发,贪心染色即可. #include<cstdio> #include<algorithm> using namespace std; int v[200010<<1],next[200010<<1],first[200010],e; void AddEdge(int U,int V) { v[++e]=V; next[e]=first[U]; first[U]=e; } bool vis[200010]; int n,col[200010]; v…
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha is an orderly boy and likes to keep things in their plac…
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放学我呆到十点然后还要跑回家耽误时间....要不然$D$题就写完了 周末一些成绩好的同学单独在艺术楼上课然后晚上下第一节晚自习和他们在回廊里玩开灯之后再关上一片漆黑真好玩 A.Andryusha and Socks 日常煞笔提.....我竟然$WA$了一次忘了$n<<1$ #include <…
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the…
Div1单场我从来就没上过分,这场又剧毒,半天才打出B,C挂了好几次最后还FST了,回紫了. AC:AB Rank:340 Rating:2204-71->2133 Div2.B.The Meeting Place Cannot Be Changed 题目大意:n个人,第i个人位于xi,速度为vi,找到一个点使得所有人到这个点的耗时最小,输出耗时.(n<=60000) 思路:二分答案,知道耗时后可以求出每个人能到达的区间,如果所有区间有交则合法,复杂度O(nlog). #include<…
http://codeforces.com/contest/782/problem/E 题目大意: 有n个节点,m条边,k个人,k个人中每个人都可以从任意起点开始走(2*n)/k步,且这个步数是向上取整的.要求:着k个人要走完所有的节点,且每个人至少走1步. 思路:= =dfs找一棵树,一棵树是n-1条边,所以从树根开始走完所有的,也就只有n*2-2步,所以不会达到上限.md这么简单都没有想到,233 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #incl…
http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用了第二种队名,那么如果队 B 的第一种队名和队 A 的相同,那么同样不能选择.当然,队B的第二个队名无所谓 思路: 学习了2-sat发现这题这么简单= =. 如果那天A了这题就前200了 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits…
地址:http://codeforces.com/contest/782/problem/E 题目: E. Underground Lab time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The evil Bumbershoot corporation produces clones for gruesome experimen…
地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in B…
地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Bytecity is a straight line from…
D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in Byteland. The first task he should do is to assign s…
先反复地扫(不超过n次),把所有可以确定唯一取法的给确定下来. 然后对于剩下的不能确定的,跑2-SAT.输出可行解时,对于a和¬a,如果a所在的强连通分量序号在¬a之前,则取a,否则不取a.如果a和¬a在同一个强连通分量,则无解. #include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstring…
三分显然,要注意EPS必须设成1e-6,设得再小一点都会TLE……坑炸了 #include<cstdio> #include<algorithm> #include<cmath> using namespace std; #define EPS 0.000001 int n,x[60010],v[60010]; double calc(double p) { double res=0; for(int i=1;i<=n;++i) res=max(res,fabs(…
翻车!翻车! codeforces782A A题: 水. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; int num[100010]; int main() { int n,x; memset(num,0,sizeof(num)); scanf("%d",&n); int sum=0,ans=0; for(int i=1;i<=2*n;i++) { scanf(…
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++.h> using namespace std; int n,m,k; ; int main() { cin>>n>>m>>k; ;i<=k-;++i) { sum+=(n+(m-))*-(i)*; } cout<<sum<<endl;…
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \(a=b\) 和 \(a=b-1\) 的时候有解,再加上一个从 \(9\) 越到 \(10\) 的就可以了.被样例的 \(199,200\) 误导了. #include<bits/stdc++.h> using namespace std; typedef long long ll; int mai…
D. Sum in the tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mitya has a rooted tree with nn vertices indexed from 11 to nn, where the root has index 11. Each vertex vv initially had…
D2. Optimal Subsequences (Hard Version) This is the harder version of the problem. In this version, 1≤n,m≤2⋅105. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems. You are given a seque…
B. Box Permutation p is a sequence of integers p=[p1,p2,-,pn], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutations: [3,4,1,2], [1], [1,2]. The following sequences are n…
题意: 给你一个由小写字母组成的字符串,若串中两个相邻元素字典序中也相邻,移除较大字母,问最多能移除多少个字母. 思路: 从大到小依次枚举. Tips: 注意下标的处理. 以小消大: #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; string s;cin>>s; int ans=0; for(char c='y';c>='a';c--){ for(int i=0;i…
题意:给出一个数列 a1 a2......an  让你构造一个序列(该序列取值(1-5)) 如果a(i+1)>a(i) b(i+1)>b(i) 如果a(i+1)<a(i)  那么b(i+1)<b(i) 如果a(i+1)==a(i) 那么b(i+1)!=b(i) 请构造该序列 如果不存在 那么输出-1 思路: 当时想的时候是贪心 但是贪心的话对于相等的时候就很不好处理 然而该题的状态比较好定义 dp[i][x] 表示 第i个位置 取x 是否成立 那么状态总量有  n(<=5e5…
A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves ciphers. He has invented his own cipher called Right-Left. Right-Left cipher is used for strings. To encr…
A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个数的数字即在A数组中出现过,也在B数组中出现过,问这个数最小是多少. 题目思路:首先要么一个数两个数组都出现过直接输出来,要么分别取两个数组中最小的数组合一下输出. 代码: //Author: xiaowuga #include <bits/stdc++.h> using namespace st…
Happy Birthday, Polycarp! Make Them Odd As Simple as One and Two Let's Play the Words? Two Fairs Beautiful Rectangle Happy Birthday, Polycarp! \[ Time Limit: 1 s\quad Memory Limit: 256 MB \] 暴力枚举所有数字全为 \(i.i\in[1,9]\),然后暴力判断有多个全为 \(i\) 的数在 \(n\) 以内即可…
Virtual participate 的,D题不会做,打了1:30就打不动了,过了ABCE. A - CME 题意:? 题解:? void test_case() { int n; scanf("%d", &n); if(n == 2) puts("2"); else printf("%d\n", n & 1); } B - Strings Equalization 题意:给两个等长的字符串,每次可以把一个字母赋值给它前一个和后…
题面戳这里 A. Diana and Liana 首先如果s>ks>ks>k一定无解,特判一下.那么我们考虑找恰好满足满足题目中的要求的区间[l,r][l,r][l,r],那么需要要删去的数一定是(l−1)%k+max((r−l+1)−k,0)(l-1)\%k+max((r-l+1)-k,0)(l−1)%k+max((r−l+1)−k,0).前面的表示要把[1,l−1][1,l-1][1,l−1]区间删成kkk的倍数,后面的表示要把这个区间删到kkk长度以内.判断这个值是否不大于能够删的…
链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have n tickets to sell. The price of the i-th ticket…
A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可. #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<map> #define LL long long #define lson rt<<1 #define rson rt<…
C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search…