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 ...
随机推荐
- Python编程实现USB转RS485串口通信
---作者吴疆,未经允许,严禁转载,违权必究--- ---欢迎指正,需要源码和文件可站内私信联系--- -----------点击此处链接至博客园原文----------- 功能说明:Python编程 ...
- JFrame 文本打印
package tools; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import jav ...
- Mavlink 协议 理解
来源:blog.csdn.net/super_mice/article/details/44836585 之前看了mavlink协议,网上关于mavlink的资料不多.本文大概总结了下对mavlink ...
- RStudio Server-0.99.902 (OpenLogic CentOS 7.2)
RStudio Server-0.99.902 (OpenLogic CentOS 7.2) 0 评论 平台: CentOS 类型: 虚拟机镜像 软件包: r-3.2.3 rstudio-server ...
- 访问mongo数据库报错
It looks like you are trying to access MongoDB over HTTP on the native driver port. 出错原因: 1.没有安装mong ...
- Linux I/O调度
一) I/O调度程序的总结 1) 当向设备写入数据块或是从设备读出数据块时,请求都被安置在一个队列中等待完成. 2) 每个块设备都有它自己的队列. 3) I/O调度程序负责维护这些队列的顺 ...
- 【POJ2774】Long Long Message(后缀数组求Height数组)
点此看题面 大致题意: 求两个字符串中最长公共子串的长度. 关于后缀数组 关于\(Height\)数组的概念以及如何用后缀数组求\(Height\)数组详见这篇博客:后缀数组入门(二)--Height ...
- ifup/ifdown ethX 和 ifconfig ehtX up/down的区别
相同点:[启用]和[禁止]网卡 ifup ethX 和 ifconfig ethX up 用来启用网卡设备 ifdown ethX 和 ifconfig ethX ...
- Java代码工具箱之超出游标最大数
1. Java大量写入oracle时容易出现此错.经过此错,也触动自己要深刻理解 java 的 prepareStatement 等对象,及数据库的连接与释放. 2. 原因:经常会出现在 for 循环 ...
- 01_13_JSP编译指令
01_13_JSP编译指令 1. Directive Directive(编译指令)相当于在编译期间的命令 格式: <%@Directive 属性=”属性值”%> 常见的Directive ...