codeforces 701 B. Cells Not Under Attack】的更多相关文章

B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequen…
题目链接: B. Cells Not Under Attack 题意: n*n的棋盘,现在放m个棋子,放一个棋子这一行和这一列就不会under attack了,每次放棋子回答有多少点还可能under attack; 思路:对行和列标记; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #incl…
B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequen…
Cells Not Under Attack 题意: 给出n*n的地图,有给你m个坐标,是棋子,一个棋子可以把一行一列都攻击到,在根据下面的图,就可以看出让你求阴影(即没有被攻击)的方块个数 题解: 我先是认真的看了前面之后,发现看不懂,最后一看图,就明白了,这就似乎证明了图片已经超越了语言,MD 扯远了. 这题要这么想,增加了一个点,就要减少一行一列,之后再把他们拼到一起,之后发现也就是求x*y了(x是行没有出现的个数,y是列没有出现的个数) 还有就是要注意这题是longlong,又被ll坑了…
比赛的时候 long long sum=n*n,计算不出1e10长度到数,没有搞掉. 哎,以后要注意这个地方.这个题其实不难: 统计能被攻击到的个数,然后用总的个数减掉就可以了.注意有些地方重复计算,要给去掉.     B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasy…
题目链接: 传送门 Cells Not Under Attack time limit per test:2 second     memory limit per test:256 megabytes Description Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on t…
Cells Not Under Attack Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another. The cell of the field is under rook's attack, if there is at le…
题目链接:http://codeforces.com/problemset/problem/701/B 题目大意: 输入一个数n,m, 生成n*n的矩阵,用户输入m个点的位置,该点会影响该行和该列,每输入一个点则输出剩余未受影响的单元数. 解题思路: 吃饭...留坑 2016.09.11 12:05 AC code: #include<bits/stdc++.h> using namespace std; int main() { int n,m,x,y,ans; long long sx,s…
A. Robot Bicorn Attack Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/175/problem/A Description Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is gi…
Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another. The cell of the field is under rook's attack, if there is at least one rook located in…
题目链接:http://codeforces.com/contest/701/problem/E 题意:有n个城市构成一棵树,一个城市最多有一个学校,这n个城市一共2*k个学校,要对这2*k个学校进行连边,使得所有连出来的边的和最大,每条边边权为1. 题解:这题有一个巧妙的解法,可以记录一下每一条边的贡献(所谓贡献就是有多少对点连线会经过这条边) 也就是记录一下这条边左端点以左的所有需要连的点x和右端点的数目就是2*k-x.然后边的贡献就是两者取 最小.这样dfs一遍所有的边就行了. #incl…
题目链接:http://codeforces.com/problemset/problem/701/D 题意:给你n个人,每个人走路的速度v1,有一辆车速度为v2,每次可以载k个人,总路程为l,每个人只能上一次车,问最少需要多少时间把所有人送到终点 题解:首先要使的时间最短肯定是所有人同时到达终点,那么肯定每人坐车的时间是相同的. 不妨设一下车一趟来回的时间为t,乘车距离为a.可以得到 (l-a)/v1+a/v2=t*(gg-1)+a/v2(意思就是最后一批人乘车到达终点时所有人同时到达终点)…
题目链接: https://codeforces.com/gym/101194 题意: 在$n×m$的各自中填上$1$到$k$的数 定义Greate cell为严格大于同行和同列的格子 定义$A_g$为存在$g$个Greate cell的方案数 求$\sum_{g=0}^{nm}(g+1)*A_g$ 数据范围: $1\leq n \leq 200$ $1\leq m \leq 200$ $1\leq k \leq 200$ 分析: $\sum_{g=0}^{nm}(g+1)*A_g=\sum_{…
http://codeforces.com/contest/701 A - Cards 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include <cstring> #include <sstream> #include <string> #include <alg…
链接: https://codeforces.com/contest/1221/problem/B 题意: You are given a chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board. A knight is a chess pi…
  ~A题 A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card gam…
B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequen…
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At…
[题意]给一个无向图的反图(即给定的边实际上不存在,而未给的边是存在的),求连通块数.(点数n<=5*10^5,边数m<=10^6) 一开始我想的用DFS,枚举每一个点,跳过不存在的点,直接扫描,时间复杂度是O(n^2)的.然后,这种方案就被抛弃了. 我们可以设一个集合st,一开始st中包含所有点,每扫描到一个连通块,就把这个连通块从st中删掉. 那么怎么求连通块,可以使用BFS+二分查找.使用邻接表存储图,vector <int> G[i]为结点i相邻的结点,预处理时将其排序为有…
题目 On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free time, he decides to put on his legendary hacker "X" instinct and fight…
由于今天实在是太自闭了就前来写场已经 AK 的 div.2 的题解了 这场比赛是我的 div.2 首 AK 哦 A 先特判 \(b=1\),强制将 \(b+1\) 否则容易发现答案最大为 \(\log_ab\),所以直接枚举 \(b\) 加了多少次,枚举到 \(30\) 就行了. B 考虑一个数组 \([a_1,a_2,\dots,a_n]\) 有多少个与其 \(k\)-similar 的数组. 对于 \(2\leq i\leq n-1\),如果我们替换 \(a_i\) 为 \(x\),那么必须…
D Multiples and Power Differences (构造) 题目大意:给一个n*m的矩阵a,a[i][j]在1到16之间.现在要构造矩阵b,需要满足如下条件: 1.b[i][j]在1到1e6之间 2.b[i][j]是a[i][j]的倍数 3.对于矩阵中任意相邻的两个数,要求存在正整数k,他们的差值绝对值等于k的四次方,不要求所有对的k都相同 构造神仙题,乍一看不可做.. 考虑第二个条件,由于a最多到16,发现1到16所有数的最小公倍数是$720720$!小于1e6. 在考虑第三…
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…
这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无比,好像三四分钟就直接A了...直接n²暴力. #include <cstdio> #include <map> #include <queue> #include <cstring> #include <algorithm> #include &l…
E - Qwerty78 Trip Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice Gym 100947E Description standard input/output Announcement   Statements Qwerty78 is a well known programmer (He is a member of the I…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output 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…
D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: standard input output :standard output The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is loca…
题目链接:http://codeforces.com/problemset/problem/701/C 题意:找到字符串中能包含所有元素的最短字符串长度. 利用“滑动窗口”解题 解题思路: 1. 遍历找到所有元素进行统计,元素数sum 2.设置两个”指针“ st.en,双重while 循环 3.先清空dp[]数组,进行统计 双重while 第一个 whielt(st<n) { 内部while(en<n&&sum!=sum1)//sum1统计元素个数 {//内部while sum…
D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to…
B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a grid with some cells that are empty and some cells that are occupied. You s…