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 面向对象初级(七)>文章介绍了面向对象基本知识: 面向对象是一种编程方式,此编程方式的实现是基于对 类 和 对象 的使用 类 是一个模板,模板中包装了多个“函数”供使 ...

  2. Linux--niaoge

    鸟哥的Linux私房菜 网络基础: 那 TCP/IP 是如何运作的呢?我们就拿妳常常连上的 Yahoo 入口网站来做个说明好了,整个联机的状态可以这样看: 应用程序阶段:妳打开浏览器,在浏览器上面输入 ...

  3. 【PHP开发篇】一个统计客户端商机提交的获取IP地址

    1.对客服提交数据的ip地址记录. 获取ip地址的方法: public function getIP() { global $ip; if (getenv("HTTP_X_REAL_IP&q ...

  4. R包igraph探究

    前段时候由于项目的原因,需要画图,然后开始接触R语言的igraph包,网上零零散散的搜罗了不少的信息,放在这边交流分享的同时也给自己留个备份吧~ 1.首先是读取文件,基本选用的都是csv文件 edge ...

  5. solr-web界面增加登录认证

    目录 配置tomcat-user.xml 配置web.xml 界面展示 回到顶部 配置tomcat-user.xml 找到 tomcat 下 conf 文件下增加 tomcat-user.xml &l ...

  6. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了(转载)

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var mysql 启动不了   ps -A | gr ...

  7. (四)SQL Server分区管理

    一.拆分分区(SPLIT) 在已有分区上添加一个新分区. 如下图所示,将分区03拆分成03和04分区,拆分方式先锁定旧03分区的所有数据,后将旧03分区相关数据迁移到分区04,最后删除旧03上的对应分 ...

  8. 如何应对ISP乱插广告(案例分析)

    一.广告从何而来? 利益让人铤而走险,从而推动行业“发展”:广告的利益还真不小,xx房产门户网站上一个广告位少则几千,多则几十万:记得在校读书的时候,刚学会做网站,第一想法就是等自己的网站发展成熟有人 ...

  9. 【Alpha版本】冲刺-Day5

    队伍:606notconnected 会议时间:11月13日 会议总结 张斯巍(433) 今天安排:完成昨天没完成的,设置界面设计 完成度:85% 明天计划:学习UI设计 遇到的问题:无 感想:一定要 ...

  10. migration integer limit option

    https://gist.github.com/stream7/1069589 :limit Numeric Type Column Size Max value 1 tinyint 1 byte 1 ...