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. Mybatis传参数

    1使用@Param注解传参数 mapper接口:public void updateUser(@Param("user")User user)throws Exception; m ...

  2. JS操作cookies方法

    /** * 写入cookies */function setCookie(name, value) { var time = "1d"; //默认一天失效 var strsec = ...

  3. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  4. win7挂载VHD文件,模拟多系统并存

    挂载vhd是win7 一个很特殊的功能,xp不能支持,一些服务器版的系统 像2008.2008R2这些可能也是支持的,只是没有测试过. 提前的准备: Win7  wim 镜像文件 Imagex.exe ...

  5. PHP变量入门教程(3)global 关键字

    global关键字 首先,一个使用 global 的例子: 使用 global <?php $a = 1; $b = 2; function Sum() { global $a, $b; $b ...

  6. 解决宿主机不能访问虚拟机CentOS中的站点 | 更新CentOS防火墙设置开启80端口访问

    前阵子在虚拟机上装好了centos6.0,并配好了nginx+php+mysql,但是本机就是无法访问.一直就没去折腾了. 具体情况如下 1.本机能ping通虚拟机 2.虚拟机也能ping通本机 3. ...

  7. Shell入门教程:流程控制(1)命令的结束状态

    在Bash Shell中,流程控制命令有2大类:“条件”.“循环”.属于“条件”的有:if.case:属于“循环”的有:for.while.until:命令 select 既属于“条件”,也属于“循环 ...

  8. jvm七种垃圾收集器

    JVM_七种垃圾收集器介绍   本文中的垃圾收集器研究背景为:HotSpot+JDK7 一.垃圾收集器概述 如上图所示,垃圾回收算法一共有7个,3个属于年轻代.三个属于年老代,G1属于横跨年轻代和年老 ...

  9. 进阶系列二【绝对干货】---Quartz.Net的入门

    一.Quartz.Net是什么? Quartz.Net是一个开源的作业调度框架,OpenSymphony的开源项目,是Quartz的C#移植项目.非常适合在平时的工作中,定时轮询数据库同步,定时邮件通 ...

  10. Maven No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题

    maven编译项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3 ...