ural1097 Square Country 2
Square Country 2
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
5 3 |
3 |
分析:参考http://blog.csdn.net/jyysc2010/article/details/9968813;
暴力枚举矩形顶点即可,复杂度o(M3);
不过感觉数据略有问题;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e2+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,k,t,b[maxn],c[maxn],ans,p,q;
struct node
{
int id,x,y,z;
node(){}
node(int _id,int _z,int _x,int _y)
{
id=_id,x=_x,y=_y,z=_z;
}
}a[maxn];
int main()
{
int i,j;
ans=;
scanf("%d%d%d",&n,&m,&k);
rep(i,,k)
{
int b,c,d,e;
scanf("%d%d%d%d",&b,&c,&d,&e);
a[i]=node(b,c,d,e);
}
a[]=node(,,,);
rep(i,,k)rep(j,,k)
{
int x=a[i].x+a[i].z,y=a[j].y+a[j].z,now=;
if(x+m->n||y+m->n)continue;
rep(t,,k)
{
if(a[t].x>x+m-||a[t].y>y+m-||a[t].x+a[t].z-<x||a[t].y+a[t].z-<y)continue;
now=max(now,a[t].id);
}
ans=min(ans,now);
}
if(ans<=)printf("%d\n",ans);
else puts("IMPOSSIBLE");
//system("Pause");
return ;
}
ural1097 Square Country 2的更多相关文章
- ural 1073. Square Country
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- 01背包 URAL 1073 Square Country
题目传送门 /* 题意:问n最少能是几个数的平方和 01背包:j*j的土地买不买的问题 详细解释:http://www.cnblogs.com/vongang/archive/2011/10/07/2 ...
- ural 1698. Square Country 5(记忆化搜索)
1698. Square Country 5 Time limit: 2.0 secondMemory limit: 64 MB The first arithmetical operation ta ...
- ural 1073.Square Country(动态规划)
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- URAL 1097 Square Country 2 离散化
一共才100个正方形,将所有正方形左下角和右上角的X坐标和Y坐标离散化,直接枚举新建公园的点的坐标即可. O(n^3)的时间复杂度. #include <cstdio> #include ...
- URAL 1073 Square Country(DP)
题目链接 题意 :这个人要投资地,每块地都是正方形并且边长都是整数,他希望他要买的地尽量的少碎块.每买一块地要付的钱是边长的平方,而且会得到一个一份证书,给你一个钱数,让你求出能得到的证书个数. 思路 ...
- Ural 1073 Square Country (DP)
题目地址:Ural 1073 DP水题.也能够说是背包. #include <iostream> #include <cstdio> #include <string&g ...
- Square Country
原题链接:http://acm.timus.ru/problem.aspx?space=1&num=1073 分析:dp,dp[i]表示钱为i且恰好用完时能买的最少土地数,易知dp[i]=mi ...
- URAL 1698. Square Country 5(记忆化搜索)
题目链接 题意 : 自守数的定义:如果某个数的平方的末尾几位数等于这个数,那么就称这个数为自守数.例如5*5=25,则5就是自守数.让你求不超过n位的自守数有多少 思路 : 实际上,自守数还有两个性质 ...
随机推荐
- 【第三篇】学习 android 事件总线androidEventbus之发布事件,子线程中接收
发送和接收消息的方式类似其他的发送和接收消息的事件总线一样,不同的点或者应该注意的地方: 1,比如在子线程构造方法里面进行实现总线的注册操作: 2,要想子线程中接收消息的功能执行,必须启动线程. 3, ...
- VBS脚本合集(自制脚本)
一.视频搜索器选择: Selectitem() '######################################### Function Selectitem() 'Set Vedio ...
- IDEA类文件不编译问题
用IDEA的人遇到过类文件上有个小叉吗? 1.在 .gitignore 里面把这个文件去掉 2.setting->builder->compiler->子目录 去掉不编译的文件
- hdu_5794_A Simple Chess(lucas+dp)
题目链接:hdu_5794_A Simple Chess 题意: 给你n,m,从(1,1)到(n,m),每次只能从左上到右下走日字路线,有k(<=100)的不能走的位置,问你有多少方案 题解: ...
- Java&&As3.0 中的final 关键字
Java和AS3.0关键字final有“这是无法改变的”或者“终态的”含义,它可以修饰非抽象类.非抽象类成员方法和变量.你可能出于两种理解而需要阻止改变:设计或效率. 可以修饰的对象: fin ...
- 哈佛大学构建动态网站--第七讲ajax
Ajax ajax举例: DOM的结构 通过js来修改html页面. Ajax的含义: return false的用途 跨浏览器的ajax 为什么不直接从yahoo获得数据呢? XMLHttpRequ ...
- 使用express创建web服务器
使用express创建web服务器 laiqun@msn.cn Contents 1. 简单的express服务器 2. 静态文件服务 3. 路由 4. 中间件 1. 简单的express服务器 安装 ...
- linux expr命令参数及用法详解
expr用法 expr命令一般用于整数值,但也可用于字符串.一般格式为: #expr argument operator argument expr也是一个手工命令行计数器. #$expr 10 + ...
- CLR 无法从 COM
上下文 0x50ece80 转换为 COM 上下文 0x50ecf38,这种状态已持续 60 秒.拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个 ...
- 在MyEclipse中运行tomcat报错 严重: Error starting static Resources
严重: Error starting static Resourcesjava.lang.IllegalArgumentException: Document base E:\apache-tomca ...