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. <<< html5本地储存

    类似与Cookies,但由于Cookies储存量太小,大小也只有4-5KB的样子,html5的本地储存能存5M大小的数据 html5本地储存属性有,localStorage和sessionStorag ...

  2. ToString和Convert.ToString处理null值

    http://www.cnblogs.com/qinge/p/5687806.html文章来源 1.Convert.ToString能处理字符串为null的情况. 测试代码如下: 1 2 3 4 5 ...

  3. 几款开源ESB总线的比较

    现有的开源ESB总线中,自从2003年第一个开源总线Mule出现后,现在已经是百花争鸣的景象了.现在我就对现有的各种开源ESB总线依据性能.可扩展性.资料文档完整程度以及整合难易程度等方面展开. CX ...

  4. iOS 关于修饰代理用weak还是assign

    对于weak:指明该对象并不负责保持delegate这个对象,delegate这个对象的销毁由外部控制. 对于strong:该对象强引用delegate,外界不能销毁delegate对象,会导致循环引 ...

  5. tyvj1192 迎春舞会之集体舞

    背景 HNSDFZ的同学们为了庆祝春节,准备排练一场舞会. 描述 表演者排成n排,构成一个向前的正三角形(在屏幕上,即向下).而就每个人,他有可能正面朝前(小的向前正三角形).或向后三角形(小的向后正 ...

  6. css 基础---选择器

    1.css基础 selector {property: value} eg: h1 {color:red; font-size:14px;} p { text-align: center; color ...

  7. 浅谈JSON

    JSON的全称是”JavaScript Object Notation”,意思是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式.XML也是一种数据交换格式,为什么没有 ...

  8. sqlserver 自增ID插入指定数据

    set identity_insert 表名 ON --允许对自增列Id插入指定数据 insert into table_name(Id,Name) values(1,'test') set iden ...

  9. MySQL SQL优化

    一.优化数据库的一般步骤: (A) 通过 show status 命令了解各种SQL的执行频率. (B) 定位执行效率较低的SQL语句,方法两种: 事后查询定位:慢查询日志:--log-slow-qu ...

  10. C++ 异常机制

    程序在运行的时候可能产生各种可预料到的异常,例如磁盘不足,内存不足,或是数学运算溢出,数组越界之类的.为了解决这些问题,C++提供了异常处理机制,它一般是由try语句和catch语句构成. 一.try ...