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. NSOprationQueue 与 GCD 的区别与选用

    原文链接:http://www.jianshu.com/p/d09e2638eb27 GCD 技术是一个轻量的,底层实现隐藏的神奇技术,我们能够通过GCD和block轻松实现多线程编程,有时候,GCD ...

  2. 入手了[云梯的VPN]--水文

    之前写的文章 http://www.cnblogs.com/rollenholt/p/3783084.html 结果很多朋友都说访问不了了,现在重新发一下: 各位看官,这是一篇水文: 在用了一段时间s ...

  3. Protobuf for Python测试保存和读取文件

    安装pip, setuptools, and wheel 如果已经从python.org,安装啦Python 2 >=2.7.9 or Python 3 >=3.4 ,那么就已经有啦pip ...

  4. mysql命令总结

    统计全库数据量: use information_schema; SELECT TABLE_NAME, (DATA_LENGTH) as DataM , (INDEX_LENGTH) as Index ...

  5. Echart的简单例子

    [转载自:http://echarts.baidu.com/echarts2/doc/start.html] <%@ page language="java" content ...

  6. Node.js入门笔记(4):文件系统(fs)

    文件系统(FileSystem) 文件系统模块 对于文件无外乎创建修改添加. File System - 文件系统模块 - require('fs') fs模块是核心模块,需要使用require导入后 ...

  7. 关于application/x-www-form-urlencoded等字符编码的解释说明

    在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型. 下边是说明: application/x-www-form-urlen ...

  8. git版本控制管理实践-2

    给网站设置一个 "根目录下的logo.ico", 还是很有必要的,比如赶集网,这时在 "历史"搜索时, 就可以根据 网站的 logo.ico 很轻松的就能够找到 ...

  9. 精选9个值得学习的 HTML5 效果【附源码】

    这里精选了一组很酷的 HTML5 效果.HTML5 是现 Web 开发领域的热点, 拥有很多让人期待已久的新特性,特别是在移动端,Web 开发人员可以借助 HTML5 强大功能轻松制作各种交互性强.效 ...

  10. 浅析Java中的final关键字

    浅析Java中的final关键字 谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关键字.另外,Java中的String类就是一个final类,那么今天我们就来 ...