题意:给定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 (思维漏洞)的更多相关文章

  1. UVALive 7512 November 11th 题解

    思路:心态大崩,最多不讲了,最少应该是三个一组,比如......应该是.S..S.,这样占的最多 代码: #include<set> #include<map> #includ ...

  2. November 11th 2016 Week 46th Friday

    Keep in mind that neither success nor failure is ever final. 无论成败,皆非定局. The final is not coming, but ...

  3. November 11th, 2017 Week 45th Saturday

    Happiness is a direction, not a place. 快乐是一个方向,不是一个目的. Do you remember those moments in your life wh ...

  4. UVALive - 6436 —(DFS+思维)

    题意:n个点连成的生成树(n个点,n-1条边,点与点之间都连通),如果某个点在两点之间的路径上,那这个点的繁荣度就+1,问你在所有点中,最大繁荣度是多少?就比如上面的图中的C点,在A-B,A-D,A- ...

  5. UVALive 5873 (几何+思维)

    唉 被秀了... 还是太弱,说好的数形结合呢,列个式子出来后就被吓到了,然后就懵逼了. 题意: 有一条狗,从原点出发,沿n个向量走,每个向量只走一次,沿着一个向量(x,y)走时,既可以往(x,y)方向 ...

  6. UVALive 3708 Graveyard(思维题)

    将原有的每个雕塑的坐标位置,映射在一个总长为n+m的数轴上,设第一个点的坐标为0,(新的等分点必然有至少有一个和原来n等分的等分点重合,因为等分点可以等距的绕圆周旋转,总可以转到有至少一个重合的,不妨 ...

  7. 2015 ACM/ICPC EC-Final

    A. Boxes and Balls 二分找到最大的不超过$n$的$\frac{x(x+1)}{2}$形式的数即可. #include <bits/stdc++.h> using name ...

  8. 任务调度框架-Quartz.Net

    使用Quartz.Net依赖于以下3个组件:Common.Logging.dll.Common.Logging.Core.dll.Quartz.dll 简单封装 using Quartz; using ...

  9. Quartz.net(调度框架) 使用Mysql作为存储

    最近公司的做的项目中涉及到配置任务地址然后按照配置去目标地址提取相关的数据,所以今天上午在Internet上查看有关定时任务(调度任务)的相关信息,筛选半天然后查找到Quartz.net. Quart ...

随机推荐

  1. 漫游Kafka设计篇之性能优化

    Kafka在提高效率方面做了很大努力.Kafka的一个主要使用场景是处理网站活动日志,吞吐量是非常大的,每个页面都会产生好多次写操作.读方面,假设每个消息只被消费一次,读的量的也是很大的,Kafka也 ...

  2. UVa 1587 Box

    题意:给出6个矩形的长和宽,问是否能够构成一个长方体 先假设一个例子 2 3 3 4 2 3 3 4 4 2 4 2 排序后 2 3 2 3 3 4 3 4 4 2 4 2 如果要构成一个长方体的话, ...

  3. 【英语】Bingo口语笔记(43) - u长短音

  4. 通过外部接口 根据ip获取城市名

    3种接口 淘宝/百度/不知名/   推荐淘宝接口 ip自个去获取,下附带php 获取ip的示例 function getIP() { static $realip; if (isset($_SERVE ...

  5. mysql now() sysdate() curdate()区别

    //mysql中now,curdate,curtime,sysdate区别 1.now 返回的时间,格式如下:2013-01-17 10:57:13 mysql> select now(),sl ...

  6. RAC 环境下的重要参数

    Oracle 数据库启动时会根据参数文件中提供的相关参数启动Oracle实例.这些参数包括数据库名字.sga,pga的分配,控制文件的位置,undo,process等等.Oracle RAC数据库同样 ...

  7. aspose.word 查找文本并加下划线

    private Run SplitRun(Run run, int position) { Run beforeRun = (Run)run.Clone(true); beforeRun.Text = ...

  8. Dapper的完整扩展(转)

    真心想说:其实...我不想用Dapper,如果OrmLite.Net支持参数化的话,也就没Dapper的什么事情了,对于OrmLite.Net只能做后续跟踪...... 这个其实是看了Dapper作者 ...

  9. Selenium启动本地firefox的profile

    ProfilesIni pi = new ProfilesIni();FirefoxProfile profile = pi.getProfile("default");WebDr ...

  10. 链接服务器"(null)"的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 返回了消息 "未指定的错误"。[手稿]

    消息 7302,级别 16,状态 1,第 1 行 无法创建链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.JET.OLEDB.4.0&qu ...