The 2016 ACM-ICPC Asia Qingdao Regional Contest
A - Relic Discovery
签到
#include <cstdio>
using namespace std;
int T,n;
long long ans=0;
int main()
{
scanf("%d",&T);
for(int t=1; t<=T; t++)
{
scanf("%d",&n);
ans=0;
for(int i=1; i<=n; i++)
{
int a,b;
scanf("%d%d",&a,&b);
ans+=a*b;
}
printf("%lld\n",ans);
}
return 0;
}
B - Pocket Cube
直接模拟六种转法。
#include <cstdio> using namespace std;
int T,n;
long long ans=0;
int st[200];
int t[200]; int check()
{
for (int j = 1; j <= 24; j += 4)
{
int i = j+'a'-1;
if (t[i] != t[i+1] || t[i+1] != t[i+2] || t[i+2] != t[i+3]) return 0;
}
return 1;
} int mov(char a, char b, char c, char d, char e, char f, char g, char h)
{
int k;
for (int i = 1; i <= 24; i++) t[i+'a'-1] = st[i+'a'-1]; for (int i = 1; i <= 2; i++)
k = t[a], t[a] = t[b], t[b] = t[c], t[c] = t[d], t[d] = t[e], t[e] = t[f], t[f] = t[g], t[g] = t[h], t[h] = k;
if (check()) return 1; for (int i = 1; i <= 24; i++) t[i+'a'-1] = st[i+'a'-1];
for (int i = 1; i <= 2; i++)
k = t[h], t[h] = t[g], t[g] = t[f], t[f] = t[e], t[e] = t[d], t[d] = t[c], t[c] = t[b], t[b] = t[a], t[a] = k;
if (check()) return 1;
return 0;
} int main()
{
int T;
scanf("%d", &T);
for (int ca = 1; ca <= T; ca++)
{
for (int i = 1; i <= 24; i++) scanf("%d", &st[i+'a'-1]);
int flag = 0; for (int i = 1; i <= 24; i++)
t[i+'a'-1] = st[i+'a'-1];
if (check()) flag = 1;
if (mov('a','c','e','g','i','k','m','o')) flag = 1;
if (mov('q','s','g','h','x','v','n','m')) flag = 1;
if (mov('q','r','a','b','u','v','l','k')) flag = 1;
if (flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}
C - Pocky
记住ln(2)=0.693147。故ans = ln(L) / ln(d)。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; int main()
{
int t;
scanf("%d", &t);
for (int ca = 1; ca <= t; ca++)
{
double l, d;
scanf("%lf%lf", &l, &d);
if (l <= d) printf("0.000000\n");
else printf("%.6f\n", 1+log(l/d));
}
}
D - Lucky Coins
E - Fibonacci
F - Lambda Calculus
G - Coding Contest
H - Pattern
I - Travel Brochure
J - Cliques
K - Finding Hotels
K-d树。题目数据有问题,爆搜也能过。下面的AC代码连样例都过不了。。这数据水的一批。
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdlib> using namespace std;
const int MAXN=2e5+100;
const int DIM=10;
inline double sqr(double x){
return x*x;
}
namespace KDTree{
int K;
struct Point{
int x[DIM];
int price, id;
double distance(const Point& b)const{
double ret=0;
for(int i=0;i<K;i++){
ret+=sqr(x[i]-b.x[i]);
}
return ret;
}
void input(int lll){
id = lll;
for(int i=0;i<K;i++)scanf("%d",&x[i]);
scanf("%d", &price);
}
void output(){
printf("%d %d %d\n",x[0], x[1], price);
}
};
struct qnode{
Point p;
double dis;
qnode(){}
qnode(Point _p,double _dis){
p=_p;dis=_dis;
}
bool operator<(const qnode &b)const{
if (fabs(dis-b.dis) < 0.00001) return p.id < b.p.id;
return dis<b.dis;
}
};
priority_queue<qnode>q;
struct cmpx{
int div;
cmpx(const int &_div){
div=_div;
}
bool operator()(const Point &a,const Point &b){
for(int i=0;i<K;i++){
if(a.x[(div+i)%K]!=b.x[(div+i)%K]){
if (a.x[(div+i)%K] !=b.x[(div+i)%K]) return a.x[(div+i)%K]<b.x[(div+i)%K];
return a.id<b.id;
}
}
return true;
}
};
bool cmp(const Point &a,const Point &b,int div){
cmpx cp=cmpx(div);
return cp(a,b);
}
struct Node{
Point e;
Node *lc,*rc;
int div;
}pool[MAXN],*tail,*root;
void init(){
tail=pool;
}
Node *build(Point *a,int l,int r,int div){
if(l>=r)return NULL;
Node *p=tail++;
p->div=div;
int mid=(l+r)/2;
nth_element(a+l,a+mid,a+r,cmpx(div));
p->e=a[mid];
p->lc=build(a,l,mid,(div+1)%K);
p->rc=build(a,mid+1,r,(div+1)%K);
return p;
}
void search(Point p,Node *x,int div,int m){
if(!x)return;
if(cmp(p,x->e,div)){
search(p,x->lc,(div+1)%K,m);
if(q.size()<m){
if (x->e.price <= p.price)
q.push(qnode(x->e,p.distance(x->e)));
search(p,x->rc,(div+1)%K,m);
}else{
if(p.distance(x->e)<q.top().dis){
if (x->e.price <= p.price)
q.pop(), q.push(qnode(x->e,p.distance(x->e)));
}
if(sqr(x->e.x[div]-p.x[div])<q.top().dis){
search(p,x->rc,(div+1)%K,m);
}
}
}else{
search(p,x->rc,(div+1)%K,m);
if(q.size()<m){
if (x->e.price <= p.price) q.push(qnode(x->e,p.distance(x->e)));
search(p,x->lc,(div+1)%K,m);
}else{
if(p.distance(x->e)<q.top().dis){
if (x->e.price <= p.price)
q.pop(), q.push(qnode(x->e,p.distance(x->e)));
}
if(sqr(x->e.x[div]-p.x[div])<q.top().dis)
search(p,x->lc,(div+1)%K,m);
}
}
}
void search(Point p,int m){
while(!q.empty())q.pop();
search(p,root,0,m);
}
};
KDTree::Point p[MAXN];
int main(){
int t;
scanf("%d", &t);
for (int ca = 1; ca<=t; ca++)
{
int n, Q;
scanf("%d%d",&n, &Q);
KDTree::K=2;
for(int i=0;i<n;i++)p[i].input(i);
KDTree::init();
KDTree::root=KDTree::build(p,0,n,0); KDTree ::Point o;
while(Q--){
o.input(1000000);
int m;
//scanf("%d",&m);
m = 1;
KDTree::search(o,1);
int cnt=0;
while(!KDTree::q.empty()){
p[cnt++]=KDTree::q.top().p;
KDTree::q.pop();
}
//printf(":::::");
p[0].output();
//printf("%d\n", p[0].id);
}
}
return 0;
}
L - Tower Attack
M - Generator and Monitor
The 2016 ACM-ICPC Asia Qingdao Regional Contest的更多相关文章
- 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分
I Count Two Three Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 2016 ACM/ICPC Asia Regional Qingdao Online(2016ACM青岛网络赛部分题解)
2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/show ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1003/HDU 5894 数学/组合数/逆元
hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1009/HDU 5900 区间dp
QSC and Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1007/HDU 5898 数位dp
odd-even number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2016 ACM/ICPC Asia Regional Dalian Online 1002/HDU 5869
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- 2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
Friends and Enemies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)
Function Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
随机推荐
- SpringBoot | 第十八章:web应用开发之WebJars使用
前言 前面一章节我们主要讲解了关于文件上传的两种方式.本章节继续web开发的相关知识点.通常对于web开发而言,像js.css.images等静态资源版本管理是比较混乱的,比如Jquery.Boots ...
- 在C#中,为什么大家用httpcontext.current,不直接用HttpContext
HttpContext只是个类名,HttpContext.Current才是一个已实例化的对象..比如这样一个类: class A{ public static A Current{get;set;} ...
- 一、Spring-Data-Jpa 初体验(基于SpringBoot)
闲话少说,首先动起来(基于springboot+gradle): 1.引入依赖 dependencies { compile 'org.springframework.boot:spring-boot ...
- CentOS 6.0 系统 LAMP(Apache+MySQL+PHP)安装步骤
一.安装 MySQL 首先来进行 MySQL 的安装.打开超级终端,输入: [root@localhost ~]# yum install mysql mysql-server 安装完毕,让 MySQ ...
- <script>, <script async>, <script defer> 三种标签的区别
<script>, <script async>, <script defer> 三种标签的区别 <script>标签 阻塞html parsing 脚 ...
- 3D向2D投影
http://blog.sina.com.cn/s/blog_536e0eaa0100jn7j.html
- 实战:ADFS3.0单点登录系列-集成SharePoint
这是本系列第四篇了,终于轮到SharePoint上场了,但是本文不会过多讲解SharePoint安装等话题,而是直入主题,讲解如何进行配置,让其于ADFS配合完成SSO的工作. 注意:本文使用的Sha ...
- POJ1061 青蛙的约会 __一维世界的爱情
由于今天上午在做数论知识的笔记,发现那时候赵老师讲的线性丢番图(求ax+by=c的特解)部分完全搞不懂,后来网上查了一下才发现这个公式就是求同余方程,所用方法就是扩展欧几里得算法.正好红皮书上有这么一 ...
- selenium跳过https的问题
背景: 周六产品给我反馈:支付成功页面后会提示这个,问自动化为什么没有发现这样的问题 第一反应:这个地址肯定被举报了,我也肯定没有设置过安全链接,因为都没有见过这样的网址,如果有问题,应该会直接出错, ...
- NBU基本常用命令
Veritas常用命令: 1. 查看当有运行的任务 bpdbjobs –report | grep Active 2. 停止任务 bpdbjobs –cancel PID (包括主任务和子任务) 3. ...