Codeforces Round #367 (Div. 2)
A题 Beru-taxi
随便搞搞。。
#include <cstdio>
#include <cmath>
using namespace std;
int a,b,n;
struct _
{
int x,y,v;
}p[];
double dis2(_ A)
{
return (a - A.x) * (a - A.x) + (b - A.y) * (b - A.y);
}
int main()
{
scanf("%d%d%d", &a, &b, &n);
; i < n; i++)
scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].v);
double ans = 1.0 * 0x3f3f3f3f;
; i < n; i++)
{
double temp = (double) sqrt(dis2(p[i])) / p[i].v;
)
ans = temp;
}
printf("%lf\n",ans);
;
}
就是找有几个不大于它的数嘛。sort一下,upperbound就行。
#include <cstdio>
#include <algorithm>
using namespace std;
+ ];
int main()
{
int n,q,x;
scanf("%d", &n);
; i < n; i++)
scanf("%d", &a[i]);
scanf("%d", &q);
sort(a,a+n);
; i < q; i++)
{
scanf("%d", &x);
int pos = upper_bound(a,a+n,x) - a;
printf("%d\n",pos);
}
;
}
C题 Hard problem
dp,加一个维度来表示,是否翻转过!!!
其次,WA了一次是因为这个判断的时候,不等号是要带等号的。>= <= 而不是> < ;
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
+ ;
const LL INF = 1e17;
int c[maxn];
LL dp[maxn][];
string s[maxn];
int main()
{
int n;
cin>>n;
; i < n; i++)
cin>>c[i];
; i < n; i++)
cin>>s[i];
//init
; i < n; i++)
{
dp[i][] = INF;
dp[i][] = INF;
}
dp[][] = ;
dp[][] = c[];
string s10,s11,s20,s21;
; i < n; i++)
{
s10 = s11 = s[i-];
reverse(s11.begin(),s11.end());
s20 = s21 = s[i];
reverse(s21.begin(),s21.end());
if(s10 <= s20)
dp[i][] = min(dp[i][], dp[i-][]);
if(s11 <= s20)
dp[i][] = min(dp[i][], dp[i-][]);
if(s10 <= s21)
dp[i][] = min(dp[i][], dp[i-][] + (LL)c[i]);
if(s11 <= s21)
dp[i][] = min(dp[i][], dp[i-][] + (LL)c[i]);
}
LL ans = min(dp[n-][], dp[n-][]);
cout<<(ans == INF ? - : ans)<<endl;
;
}
据说是裸的字典树orz。
01字典树
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
#define mem(x,y) memset(x, y, sizeof(x))
#define lson l,m,rt << 1
#define rson m+1,r,rt << 1 | 1
const int INF = 0x3f3f3f3f;
;
int n;
;//种类数目调节
struct node
{
node *next[trie_size];
int cnt;
node()
{
; i < trie_size; i++)
next[i] = NULL;
cnt = ;
}
};
node *p, *root = new node();
void trie_insert(int x)
{
p = root;
; i >= ; i--)
{
<< i) ? : ;
if(p->next[num] == NULL)
p->next[num] = new node();
p = p->next[num];
p->cnt++;
}
}
void trie_delete(int x)
{
p = root;
;i >= ; i--){
<< i) ? : ;
p = p -> next[num];
p->cnt--;
}
}
int trie_query(int x)
{
;
p = root;
; i >= ; i--)
{
<< i) ? : ;
node *temp;
temp = p->next[num];
)
{
res += << i;
p = temp;
}
else
{
p = p->next[!num];
}
}
return res;
}
int main()
{
trie_insert();
scanf("%d", &n);
; i < n; i++)
{
char ch;
int x;
getchar();
scanf("%c%d", &ch, &x);
if(ch == '+')
{
trie_insert(x);
}
else if(ch == '-')
{
trie_delete(x);
}
else if(ch == '?')
{
int ans = trie_query(x);
printf("%d\n", ans);
}
}
;
}
Codeforces Round #367 (Div. 2)的更多相关文章
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset (0/1-Trie树)
Vasiliy's Multiset 题目链接: http://codeforces.com/contest/706/problem/D Description Author has gone out ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset
题目链接:Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset 题意: 给你一些操作,往一个集合插入和删除一些数,然后?x让你找出与x异或后的最大值 ...
- Codeforces Round #367 (Div. 2) C. Hard problem
题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字 ...
- Codeforces Round #367 (Div. 2) (A,B,C,D,E)
Codeforces Round 367 Div. 2 点击打开链接 A. Beru-taxi (1s, 256MB) 题目大意:在平面上 \(n\) 个点 \((x_i,y_i)\) 上有出租车,每 ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset(01字典树求最大异或值)
http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给 ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset Trie
题目链接: http://codeforces.com/contest/706/problem/D D. Vasiliy's Multiset time limit per test:4 second ...
随机推荐
- 在github上搭建hexo博客
准备工作 安装git 系统是win10家庭版,采用git v1.9.5版本,比较简单,一路next直到finsh完成安装. 安装node.js hexo是基于node.js驱动的一款快速.简单且功能强 ...
- VirtualBox Guest Additions 在CentOS中无法安装的解决方法
安装时出现一步错误查看log为(log文件是 /var/log/vboxadd-install.log): /tmp/vbox.0/Makefile.include.header:94: *** Er ...
- web在线打印,打印阅览,打印维护,打印设计
winform打印的方案比较多,实现也比较容易,而且效果也非常炫:但现在越来越多的系统是web系统,甚至是移动端.网上也有非常的web打印方案,但各式各样的问题非常多,比如js兼容性,稳定性等一直缠绕 ...
- @SuppressWarnings的参数
@SuppressWarnings 是J2EE的最后一个批注,该批注的作用是告诉编译器对被批注的元素内部的某些警告保持静默 @SuppressWarnings("unchecked" ...
- javascript数据结构与算法--高级排序算法
javascript数据结构与算法--高级排序算法 高级排序算法是处理大型数据集的最高效排序算法,它是处理的数据集可以达到上百万个元素,而不仅仅是几百个或者几千个.现在我们来学习下2种高级排序算法-- ...
- Js循环读取JSON数据
<script> $(function () { var jsonString = '{Unid:"1",CustomerName:"宋江",Age ...
- Hadoop里的数据挖掘应用-Mahout——学习笔记<三>
之前有幸在MOOC学院抽中小象学院hadoop体验课. 这是小象学院hadoop2.X的笔记 由于平时对数据挖掘做的比较多,所以优先看Mahout方向视频. Mahout有很好的扩展性与容错性(基于H ...
- 【总结】/etc/rc.d/rc.local 与 /etc/profile .bash_profile .bashrc 文件执行顺序
登陆shell与交互式非登陆shell的区别 登录shell 所谓登录shell,指的是当用户登录系统时所取的那个 shell.登录shell属于交互式shell. 登录shell将查找4个不同的启动 ...
- Cookie使用时需要注意个数及大小限制
各浏览器对Cookie有一定的限制,在使用时需要格外注意. 各浏览器之间对cookie的不同限制: IE6.0 IE7.0/8.0/9.0+ Opera FF Safari Chrome cook ...
- MFC之进度条CProgressCtrl
一.成员函数简介 1.create()针对不是通过资源文件上拖拉进度条控件生成的进度条,需要用此函数创建一个. 2.SetRange()设置进度条的起始值和终止值. 3.SetPos()设置进度条的当 ...