UVaLive 7512 November 11th (思维漏洞)
题意:给定n*m个座椅,然后有b个是坏的,要做人,并且两个人不能相邻,问你最多坐多少人,最少坐多少人。
析:这个题其实并不难,只要当时一时没想清楚,结果就一直WA,就是最少的情况时,其实一个人可以占三个座位,而不是两个,就是这一点没想清楚,其他的就简单了。
代码如下:
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e6 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0}; int n, m, q;
vector<int> a[1010]; int main(){
int T, ca = 0;
scanf("%d", &T);
while(T--){
scanf("%d %d %d", &n, &m, &q);
for(int i = 0; i <= n; ++i) a[i].clear();
int tmp1, tmp2;
while(q--){
scanf("%d %d", &tmp1, &tmp2);
a[tmp1 + 1].push_back(tmp2 + 1);
}
for(int i = 1; i <= n; ++i) sort(a[i].begin(), a[i].end());
int ans1 = 0, ans2 = 0;
for(int line = 1; line <= n; ++line){
if(a[line].empty()){
ans1 += (m+1) / 2;
ans2 += (m+2) / 3;
continue;
}
int head = 0, len = a[line].size();
for(int i = 0; i < len; ++i){
int lur = a[line][i];
int cha = lur - head - 1; ans1 += (cha+1) / 2;
ans2 += (cha+2) / 3;
head = lur;
} int lur = m + 1;
int cha = lur - head - 1;
ans1 += (cha+1) / 2;
ans2 += (cha+2) / 3;
}
printf("Case #%d: %d %d\n", ++ca, ans1, ans2);
}
return 0;
}
UVaLive 7512 November 11th (思维漏洞)的更多相关文章
- UVALive 7512 November 11th 题解
思路:心态大崩,最多不讲了,最少应该是三个一组,比如......应该是.S..S.,这样占的最多 代码: #include<set> #include<map> #includ ...
- November 11th 2016 Week 46th Friday
Keep in mind that neither success nor failure is ever final. 无论成败,皆非定局. The final is not coming, but ...
- November 11th, 2017 Week 45th Saturday
Happiness is a direction, not a place. 快乐是一个方向,不是一个目的. Do you remember those moments in your life wh ...
- UVALive - 6436 —(DFS+思维)
题意:n个点连成的生成树(n个点,n-1条边,点与点之间都连通),如果某个点在两点之间的路径上,那这个点的繁荣度就+1,问你在所有点中,最大繁荣度是多少?就比如上面的图中的C点,在A-B,A-D,A- ...
- UVALive 5873 (几何+思维)
唉 被秀了... 还是太弱,说好的数形结合呢,列个式子出来后就被吓到了,然后就懵逼了. 题意: 有一条狗,从原点出发,沿n个向量走,每个向量只走一次,沿着一个向量(x,y)走时,既可以往(x,y)方向 ...
- UVALive 3708 Graveyard(思维题)
将原有的每个雕塑的坐标位置,映射在一个总长为n+m的数轴上,设第一个点的坐标为0,(新的等分点必然有至少有一个和原来n等分的等分点重合,因为等分点可以等距的绕圆周旋转,总可以转到有至少一个重合的,不妨 ...
- 2015 ACM/ICPC EC-Final
A. Boxes and Balls 二分找到最大的不超过$n$的$\frac{x(x+1)}{2}$形式的数即可. #include <bits/stdc++.h> using name ...
- 任务调度框架-Quartz.Net
使用Quartz.Net依赖于以下3个组件:Common.Logging.dll.Common.Logging.Core.dll.Quartz.dll 简单封装 using Quartz; using ...
- Quartz.net(调度框架) 使用Mysql作为存储
最近公司的做的项目中涉及到配置任务地址然后按照配置去目标地址提取相关的数据,所以今天上午在Internet上查看有关定时任务(调度任务)的相关信息,筛选半天然后查找到Quartz.net. Quart ...
随机推荐
- 堆Heap
#pragma once#include <vector> // 小堆template<class T> //仿函数struct Less{ bool opera ...
- [Swift 语法点滴]—— Struct Vs Class
摘自:stackoverflow.com/questions/24232799/why-choose-struct-over-class Structure instances are always ...
- IOS中UISearchBar的使用
1.搜索框的代理(delegate)方法 #pragma mark 监听搜索框的文字改变 - (void)searchBar:(UISearchBar *)searchBar textDidChang ...
- HDU2028 Lowest Common Multiple Plus
解题思路:最近很忙,有点乱,感觉对不起自己的中国好队友. 好好调整,一切都不是问题,Just do it ! 代码: #include<cstdio> int gcd(int a, i ...
- 【英语】Bingo口语笔记(60) - 口语中的浊化发音
- 【转】为eclipse安装python、shell开发环境和SVN插件
原文网址:http://www.crazyant.net/1185.html eclipse是一个非常好用的IDE,通常来说我们都用eclipse来开发JAVA程序,为了让开发python.shell ...
- java批量插入或更新的问题
在批量插入或者更新中,setXXX的时候字段类型必须一致.例如:在普通sql中 pstmt8.setBigDecimal(j ,xxx);可以写成pstmt8.setString(j,xxx.toSt ...
- word添加页码
问:在Word里面,分两栏插入页码,怎么使两栏都有页码? 可以通过插入域来实现分两栏后两栏都有页码.左边一栏页码为 当前页页码×2-1 :右边一栏页码为 当前页页码×2.在页眉页脚视图中,分别在左右两 ...
- WebApp开发经验
1.自适应屏幕 <meta name="viewport" id="viewport" content="width = device-widt ...
- nagios监控远程主机端口
1 被监控主机上的操作 修改nrpe插件内容: 在其中增加的内容如下: 表示的含义为监控主机的端口631和661,这个主要是监控命令 重启xinetd服务: 2 监控主机上的操作 查看监控命令配置文件 ...