CodeForces 989C】的更多相关文章

传送门:http://codeforces.com/contest/989/problem/C 这是一个构造问题. 构造一张网格,网格中的字符为’A’.’B’.’C’.’D’,并且其连通块的个数分别为a.b.c.d. 首先我们可以考虑两种颜色的情形: 构造一张网格,网格中的字符为’0’.’1’,并且其连通块的个数分别为a.b,其中a.b均为正整数.于是,至少为’0’.’1’分别构造一个连通块:再分别以连通块为“网”,植入’1’.’0’,植入时应保证植入的点互不连通.如下图所示: 以上构造法可以推…
题意: 让你构造一个图,使得A,B,C,D的个数为给定的个数,上下左右连通的算一个. 哎呀 看看代码就懂了..emm..很好懂的 #include <bits/stdc++.h> using namespace std; , INF = 0x7fffffff; ][]; int main() { ; i<; i++) ; j<; j++) ) str[i][j] = 'A'; else str[i][j] = 'B'; int a, b, c, d; cin>> a &…
题意略. 思路:如图 详见代码: #include<bits/stdc++.h> #define maxn 55 using namespace std; char board[maxn][maxn]; void init(){ ;i <= ;++i){ ;j <= ;++j){ board[i][j] = 'A'; } } ;i <= ;++i){ ;j <= ;++j){ board[i][j] = 'B'; } } ;i <= ;++i){ ;j <=…
A - Jzzhu and Cities CodeForces - 449B 题意:n座城市,m条路,k条铁路啥的吧,然后要求最多能删多少条铁路保持1到$n$的最短路不变. 思路:因为铁路是从1出发的.所以能删的铁路有该铁路长度不等于1到该节点的最短路的,相等的时候,如果该节点的入度非1,也可以删去. #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #in…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连通图)且这颗树中必须包含节点1 然后将这颗子树中的所有点的点权+1或-1 求把所有点权全部变为0的最小次数(n<=10^5) 题解: 因为每一次的子树中都必须有1,所以我们得知每一次变换的话1的权值都会变化 所以我们以1为根 现在,我们发现,如果一个节点的权值发生变化,那么他的父节点的权值一定发生变…