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);
     ;
 }

B题  Interesting drink

就是找有几个不大于它的数嘛。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;

     ;
 }

D题  Vasiliy's Multiset

据说是裸的字典树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);
         }
     }
     ;
 }

E题  Working routine

 
 
 
 
 
 
 
 
 
 

Codeforces Round #367 (Div. 2)的更多相关文章

  1. 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 ...

  2. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  3. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

  4. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  5. Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset

    题目链接:Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset 题意: 给你一些操作,往一个集合插入和删除一些数,然后?x让你找出与x异或后的最大值 ...

  6. Codeforces Round #367 (Div. 2) C. Hard problem

    题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字 ...

  7. 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)\) 上有出租车,每 ...

  8. Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset(01字典树求最大异或值)

    http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给 ...

  9. 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 ...

随机推荐

  1. python内置函数

    python内置函数 官方文档:点击 在这里我只列举一些常见的内置函数用法 1.abs()[求数字的绝对值] >>> abs(-13) 13 2.all() 判断所有集合元素都为真的 ...

  2. Elasticsearch集群状态脚本及grafana监控面板导出的json文件

    脚本文件: #!/usr/bin/env python import datetime import time import urllib import json import urllib2 imp ...

  3. [Web开发] 在HTML代码里面如何判断IE版本

    在上一篇blog里面提到IE有不同的显示模式以及如何用Javascript 来动态判定. Web开发者可以根据不同显示模式导入不同的内容.这篇blog 主要讲如何让静态HTML代码根据不同IE版本显示 ...

  4. mysql 递归查询

    1.创建表: DROP TABLE IF EXISTS `t_areainfo`; CREATE TABLE `t_areainfo` ( `id` ) ' AUTO_INCREMENT, `) ', ...

  5. 6Hibernate进阶----青软S2SH(笔记)

    关于关联关系的配置,用注解配置如下(这里引用的jar包是javax.persistence) // @ManyToOne(fetch=FetchType.LAZY) @ManyToOne(fetch= ...

  6. postgresql:pgadmin函数调试工具安装过程

    通过安装第三方插件pldebugger,可实现在pgadmin客户端对函数设置断点.调试,具体过程如下: 1.下载pldebugger安装包:http://git.postgresql.org/git ...

  7. 快速傅里叶(FFT)的快速深度思考

    关于按时间抽取快速傅里叶(FFT)的快速理论深度思考 对于FFT基本理论参考维基百科或百度百科. 首先谈谈FFT的快速何来?大家都知道FFT是对DFT的改进变换而来,那么它究竟怎样改进,它改进的思想在 ...

  8. jQuery如何判断元素是否是隐藏的?

    jQuery函数简介: is(expr) 用一个表达式来检查当前选择的元素集合,如果其中至少有一个元素符合这个给定的表达式就返回true. 如果没有元素符合,或者表达式无效,都返回'false'. 注 ...

  9. 关于Azure带宽的测试

    以前见客户经常会碰到一些客户问我们你们Azure的带宽是多少,每次回答这个问题我们只能含糊地告诉客户一个大概数值,这样就会留给客户一个认为我们很不专业的印象,其实站在客户的角度我们也能理解,连这样的一 ...

  10. 1.1ASP.NET Web API 2入门

    HTTP 不只是为了生成 web 页面.它也是建立公开服务和数据的 Api 的强大平台.HTTP 是简单的. 灵活的和无处不在.你能想到的几乎任何平台有 HTTP 库,因此,HTTP 服务可以达到范围 ...