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 ...
随机推荐
- node线程有多少
一篇文章构建你的 NodeJS 知识体系
- CentOS 6.2安装nagios
nagios分为监控机和被监控机两类机器 监控主机:gserver150(192.168.111.150) 被监控主机:gserver151(192.168.111.151) 一. 监 ...
- Android入门:封装一个HTTP请求的辅助类
前面的文章中,我们曾经实现了一个HTTP的GET 和 POST 请求: 此处我封装了一个HTTP的get和post的辅助类,能够更好的使用: 类名:HttpRequestUtil 提供了如下功能: ( ...
- BZOJ4355: Play with sequence(吉司机线段树)
题意 题目链接 Sol 传说中的吉司机线段树??感觉和BZOJ冒险那题差不多,就是强行剪枝... 这题最坑的地方在于对于操作1,$C >= 0$, 操作2中需要对0取max,$a[i] > ...
- VC使用编译时间作为版本号
常用方法分两步:1. 得到编译时间:2. 设置基准时间,以编译时间距基准时间的总天数的2倍作为版本号,适当情况还可加上初值: 其中第一步实现有两种方法: 1. 直接使用系统宏:CString OcxT ...
- 《Python高效开发实战》实战演练——基本视图3
在完成Django项目和应用的建立后,即可以开始编写网站应用代码,这里通过为注册页面显示一个欢迎标题,来演示Django的路由映射功能. 1)首先在djangosite/app/views.py中建立 ...
- meterpreter > run post/windows/capture/keylog_recorder
meterpreter > migrate 1548[*] Migrating to 1548...[*] Migration completed successfully.meterprete ...
- 比特币中P2SH(pay-to-script-hash)多重签名的锁定脚本和解锁脚本
P2SH(pay-to-script-hash)多重签名的脚本 P2SH是多重签名的一种应用形式.在P2SH的交易中,多了一个Redeem Script的概念,称为赎回脚本.当向P2SH脚本的地址转账 ...
- 模块化Java简介
什么是模块化? 模块化是个一般概念,这一概念也适用于软件开发,可以让软件按模块单独开发,各模块通常都用一个标准化的接口来进行通信.实际上,除了规模大小有区别外,面向对象语言中对象之间的关注点分离与 ...
- 简析平衡树(二)——Treap
前言 学完了替罪羊树,我决定再去学一学\(Treap\).一直听说\(Treap\)很难,我也花了挺久才学会. 简介 \(Treap\)这个名字真的挺有内涵: \(\color{red}{Tree}\ ...