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 ...
随机推荐
- Typescript Mixins(混合)
除了惯例的面对对象的思想,另一种较流行的通过可复用组件创建类的方法是将简单的类混合到一起.你可能对这种混合的方式比较熟悉或对Scala语言的特性有理解,这种模式在JavaScript社区也有一定的人气 ...
- Codeforces Round #342 (Div. 2) C. K-special Tables(想法题)
传送门 Description People do many crazy things to stand out in a crowd. Some of them dance, some learn ...
- Tarjan三把刀
搞过OI的对tarjan这个人大概都不陌生.这个人发明了很多神奇的算法,在OI届广被采用. 他最广泛采用的三个算法都是和$dfn$,$low$相关的. 有向图求强连通分量 其实说直白点,就是缩点.用得 ...
- 【转】javascript面向对象编程
摘要:本文本来是想自己写的,奈何花了好长时间写好之后忘记保存,还按了刷新键,一键回到解放前,索性不写了,所以本文是转载的. 面向对象编程是用抽象方式创建基于现实世界模型的一种编程模式,主要包括模块化. ...
- HTML颜色、超链接设置
<html> <head> <title>显示的页面选项卡标题</title> <style type="text/css"& ...
- Windows的基本内容
1, 进程间通信:是指进程间进行信息交换 低级方式:信号量通信(可以交换的信息量少的时候) 高级通信方式(3种):1.共享存储器系统(剪贴板) 2.消息传递系统(进程间的数据交换以消息(message ...
- [Unity] Shader - CG语言 和 HLSL语言
CG 跟 HLSL几乎是一摸一样的. (HLSL官方参考,包含语法格式,函数库,关键字,在这个地方: http://msdn.microsoft.com/en-us/library/bb509638( ...
- iframe子页面点击按钮,执行父页面的点击事件
iframe 子页面点击.parent 父页面 的id(auth-link-btn)的事件 <a href="javascript:void(0);" onclick=&q ...
- ASP.NET AJAX调用 WebService
同事的代码,帮忙修改的,为了实现页面跳转回来后,状态的保持,Service 使用了Session. 主要的JS $.ajax({ url: "/ws/StaffInfo.asmx/Note& ...
- Navigation Bar options for Android (based on photosomething project)
1, Tab控件即标签页,可以在一页中切换显示n页内容,要使用此效果,需要用到TabHost和Tabwidget类.(过时了?) Tab控件具有两种实现过程,一是在同一个Activity中切换显示不同 ...