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 ...
随机推荐
- php.ini 中文注释
这个文件控制了PHP许多方面的观点.为了让PHP读取这个文件,它必须被命名为 ; ´php.ini´.PHP 将在这些地方依次查找该文件:当前工作目录:环境变量PHPRC ; 指明的路径:编译时指定的 ...
- C#------接口的理解
转载: http://blog.jobbole.com/85751/
- 11月13日上午ajax返回数据类型为JSON数据的处理
ajax返回数据类型为JSON数据的处理 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...
- Google Map API V3开发(6) 代码
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- JQuery常用方法总结
1.json的创建方式 <script> $(function () { //第一种 var my = new People("CallmeYhz", 26); ale ...
- [Head First设计模式]山西面馆中的设计模式——观察者模式
系列文章 [Head First设计模式]山西面馆中的设计模式——装饰者模式 引言 不知不自觉又将设计模式融入生活了,吃个饭也不得安生,也发现生活中的很多场景,都可以用设计模式来模拟.原来设计模式就在 ...
- util类中非静态方法中注入serivce,在controller层是使用util。
今天碰到如题的问题,刚一开始在util中注入service总是注入失败,起初我以为是util中没有注入成功,debug看了一下果然注入不进来. 然后各种纠结,最终坑爹的问题是在controller直接 ...
- 各大浏览器hack
浏览器界的奇葩IE 样式前缀法,在需要制定某些浏览器只识别其中某些属性的时候: chrome/safari 都是webkit内核的浏览器.在属性前加前缀-webkti- firefox 只在火狐浏览器 ...
- django orm字段和参数
字段 1.models.AutoField 自增列 = int(11) 如果没有的话,默认会生成一个名称为 id 的列,如果要显示的自定义一个自增列,必须将给列设置为主键 primary_key=Tr ...
- 数据库分库分表(sharding)系列(一) 拆分规则
第一部分:实施策略 数据库分库分表(sharding)实施策略图解 1. 垂直切分垂直切分的依据原则是:将业务紧密,表间关联密切的表划分在一起,例如同一模块的表.结合已经准备好的数据库ER图或领域模型 ...