[Agc029D]Grid game_贪心】的更多相关文章

Grid game 题目链接:https://atcoder.jp/contests/agc029/tasks/agc029_d 数据范围:略. 题解: 方法肯定很简单,就是找一处障碍待在他上面就好. 那就随便搞一搞呗 代码: #include <bits/stdc++.h> #define N 300010 using namespace std; char *p1, *p2, buf[100000]; #define nc() (p1 == p2 && (p2 = (p1…
题意:给一个\(n\)X\(m\)的矩阵,矩阵中某个数字\(k\)表示其四周恰好有\(k\)个不为0的数字,你可以使任意位置上的数字变大,如果操作后满足条件,输出新矩阵,否则输出NO. 题解:贪心,既然能使任意位置加大任意数值,那么我们可以将所有位置都给他填满,这样的话,只要是满足条件的情况就都能这样输出,所以我们遍历每个位置,然后判断周围能填多少个,如果某个数大于周围能填的个数,那么就不满足条件. 代码: int t; int n,m; int a[400][400]; int dx[4]={…
题目链接: C - Grid of Lamps Time Limit:1000MSMemory Limit: 0KB 问题描述 We have a grid of lamps. Some of the lamps are on, while others are off. The luminosity of a row/column is the number of its lighted lamps. You are given a permutation of the luminositie…
题意:给出每行每列至少有的灯泡数,问最少有的灯泡数. 解法:要使灯泡数尽量小,说明要使交叉点尽量多,这样即抵了行,又抵了列,为最优的.所以可以用行来消去列,也可以用列来消去行,我这里是列来消去行.首先将列的灯泡数排个序,从大到小枚举,同时每次行的数也要有序,可以直接排序或者用优先队列,然后一个一个消去,最后加上两个部分还剩下的即是答案. 注意优先队列不要搞多了,比如用来过渡的队列不要用优先队列,因为优先队列还要排序,会超时的. 代码: #include <iostream> #include…
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…
题目链接: 传送门 Lawnmower time limit per test:2 second     memory limit per test:256 megabytes Description You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, an…
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/A Description You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square r…
On or Off Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93265#problem/C Description Saving electricity is very important! You are in the office represented as R \times C grid that consists of walls…
Description Drazil created a following problem about putting  ×  tiles into an n × m grid: "There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should c…
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned into a game player of minecraft. On that day, Clarke set up local network and chose create mode for sharing his achievements with others. Unfortunately…