A. Bark to Unlock

题目链接:http://codeforces.com/contest/868/problem/A

题目意思:密码是两个字符组成的,现在你有n个由两个字符组成的字符串,现在问是否可以用你手上的这些字符串通过拼接其中两个的基础上使得密码是这个拼接而成的字符串的子串,一个字符串可以使用多次,这意味这自己拼接自己也是可以的。

题目思路:暴力枚举这个过程,因为总共就n最大也就100

代码:

  1. /* ***********************************************
  2. Author :xiaowuga
  3. Created Time :2017年10月05日 星期四 15时07分23秒
  4. File Name :A.cpp
  5. ************************************************ */
  6. #include <bits/stdc++.h>
  7. typedef long long LL;
  8. #define endl "\n"
  9. #define inf 0x3f3f3f3f
  10. const long long N=;
  11. const long long mod=1e9+;
  12. using namespace std;
  13. int main(){
  14. ios::sync_with_stdio(false);cin.tie();
  15. string q;
  16. cin>>q;
  17. int n;
  18. cin>>n;
  19. string a[];
  20. for(int i=;i<n;i++) cin>>a[i];
  21. for(int i=;i<n;i++){
  22. for(int j=i;j<n;j++){
  23. string s=a[i]+a[j];
  24. if(s.find(q)!=string::npos){
  25. cout<<"YES"<<endl;
  26. return ;
  27. }
  28. string ss=a[j]+a[i];
  29. if(ss.find(q)!=string::npos){
  30. cout<<"YES"<<endl;
  31. return ;
  32. }
  33. }
  34. }
  35. cout<<"NO"<<endl;
  36. return ;
  37. }

B. Race Against Time

题目链接:http://codeforces.com/contest/868/problem/B

题目意思:现在时间停止了。给你一个时间,表示现在指针在钟面上的分布情况,问点a是否可以到达点b(如果点a无法到达b说明,不管a顺时针走还是逆时针走都是碰到指针,以至于无法到达B)。

题目思路:这个题目有一个坑点导致wa了很多人,就是比如十点四十五分三十秒,我们发现时针和秒针都不是在刚好整格的地方,这就说明这个题需要一个精度问题。所以我们把分针和秒针的贡献都算在时针上,秒针对分针的贡献算在分针上,然后看一下,如果是三个指针都在ab点之间就说明可以到达,否则不行。

代码:

  1. /* ***********************************************
  2. Author :xiaowuga
  3. Created Time :2017年10月05日 星期四 15时37分27秒
  4. File Name :B.cpp
  5. ************************************************ */
  6. #include <bits/stdc++.h>
  7. typedef long long LL;
  8. #define endl "\n"
  9. #define inf 0x3f3f3f3f
  10. const long long N=;
  11. const long long mod=1e9+;
  12. using namespace std;
  13. double a[]={,,,,,,,,,,,,};
  14. int main(){
  15. ios::sync_with_stdio(false);cin.tie();
  16. int hh,tt1,tt2;
  17. double m,s;
  18. cin>>hh>>m>>s>>tt1>>tt2;
  19. double h=a[hh]+1.0**m/+1.0**s/;
  20. m=m+1.0*s/;
  21. int t1=a[tt1];
  22. int t2=a[tt2];
  23. int c1=,c2=;
  24. if(t1>t2) swap(t1,t2);
  25. if(h>t1&&h<t2) c1++;
  26. else c2++;
  27. if(m>t1&&m<t2) c1++;
  28. else c2++;
  29. if(s>t1&&s<t2) c1++;
  30. else c2++;
  31. if(c1==||c2==) cout<<"YES"<<endl;
  32. else cout<<"NO"<<endl;
  33. return ;
  34. }

C. Qualification Rounds

题目链接:http://codeforces.com/contest/868/problem/C

题目意思:有k个队伍n个题目,现在要从n个问题中找到一个子集,使得k个队伍中没有一个队伍会做这个子集中超过一半题目。

题目思路:只要出两个题目就可以了,把每道题的掌握情况压成一个十进制数,然后暴力枚举所有的数,看一下是否有两个数&在一起为0。保证会做其中一道题的一定不会做另一到题。

代码:

  1. /* ***********************************************
  2. Author :xiaowuga
  3. Created Time :2017年10月05日 星期四 18时02分29秒
  4. File Name :C.cpp
  5. ************************************************ */
  6. #include <bits/stdc++.h>
  7. typedef long long LL;
  8. #define endl "\n"
  9. #define inf 0x3f3f3f3f
  10. const long long N=;
  11. const long long mod=1e9+;
  12. using namespace std;
  13. int a[];
  14. vector<int>b;
  15. int main(){
  16. ios::sync_with_stdio(false);cin.tie();
  17. int n,k;
  18. cin>>n>>k;
  19. for(int i=;i<n;i++){
  20. int sum=;
  21. for(int j=;j<k;j++){
  22. sum*=;
  23. int t;
  24. cin>>t;
  25. sum+=t;
  26. }
  27. a[sum]++;
  28. }
  29. for(int i=;i<=(<<k);i++) if(a[i]) b.push_back(i);
  30. if(b[]==){cout<<"YES"<<endl;return ;}
  31. for(int i=;i<b.size()-;i++){
  32. for(int j=i+;j<b.size();j++){
  33. int t=b[i]&b[j];
  34. if(!t){ cout<<"YES"<<endl;return ;}
  35. }
  36. }
  37. cout<<"NO"<<endl;
  38. return ;
  39. }

Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)的更多相关文章

  1. D. Huge Strings Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

    http://codeforces.com/contest/868/problem/D 优化:两个串合并 原有状态+ 第一个串的尾部&第二个串的头部的状态 串变为第一个串的头部&第二个 ...

  2. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine

    最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛 A. Bark to Unlock time limit per test 2 seconds memory limit per t ...

  3. Qualification Rounds(Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)+状态压缩)

    题目链接 传送门 题意 现总共有\(n\)个题目\(k\)支参赛队伍,已知每个题目各队伍是否会写,现问你能否从题目中选出一个子序列使得每支队伍最多只会写一半的题目. 思路 对于每个题目我们用二进制压缩 ...

  4. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A,B,C【真的菜·】

    8说了 #include<bits/stdc++.h> using namespace std; #define int long long signed main(){ string s ...

  5. Codeforces Round #438 (Div.1+Div.2) 总结

    本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...

  6. Codeforces Round #438 B. Race Against Time

    Description Have you ever tried to explain to the coordinator, why it is eight hours to the contest ...

  7. Codeforces Round #438 C. Qualification Rounds

    Description Snark and Philip are preparing the problemset for the upcoming pre-qualification round f ...

  8. Codeforces Round #438 C - Qualification Rounds 思维

    C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. Codeforces Round #438 D. Huge Strings

    Description You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations a ...

随机推荐

  1. python 向qq邮箱发邮件

    #coding:utf-8 ''' Created on 2017-1-12 @author: xiaochun ''' import smtplib from email.mime.text imp ...

  2. 【转载】PADS Layout将导入DXF,并转换成板框步骤

    1.在PADS Layout中选择 Import... 2.选择DXF文件(一般由结构工程师给出),直接点OK即可. 3.导入后,板框图一角视图如下.右键选择 Select Shapes,然后双击外框 ...

  3. php eval函数一句话木马代码

    eval可以用来执行任何其他php代码,所以对于代码里发现了eval函数一定要小心,可能是木马 就这一句话害死人,这样任何人都可以post任何文件上来,所以要做好防范 <?php @eval($ ...

  4. u3d发布成全屏的方式

    using UnityEngine;   using System.Collections;   public class example : MonoBehaviour {   public voi ...

  5. dwr框架使用总结——简单示例

    1.新建web项目,项目名为dwr 2.导入以下jar包: dwr.jar.classes12.jar.commons-logging-1.0.4.jar和commons-logging.jar 3. ...

  6. OpenCV学习:Mat结构中的数据共享机制

    使用Mat类,内存管理变得简单,不再像使用IplImage那样需要自己申请和释放内存. Mat是一个类,由两个数据部分组成:矩阵头(包含矩阵尺寸,存储方法,存储地址等信息)和一个指向存储所有像素值的矩 ...

  7. meta标签整理

    meta指元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词.标签位于文档的头部,不包含任何内容. 标签的属性定义了与文档相关联的名称/值对. 一 ...

  8. 【jersey】 spring 整合jersey 实现RESTful webservice

         Jersey是一个RESTFUL请求服务JAVA框架,与常规的JAVA编程使用的struts框架类似,它主要用于处理业务逻辑层.与Struts类似,它同样可以和hibernate,sprin ...

  9. 在WCF中实现双工通信

    双工(Duplex)模式的消息交换方式体现在消息交换过程中,参与的双方均可以向对方发送消息.基于双工MEP消息交换可以看成是多个基本模式下(比如请求-回复模式和单项模式)消息交换的组合.双工MEP又具 ...

  10. 一这hash算法

    public static long hash(byte[] digest, int nTime)         {             long rv = ((long)(digest[3 + ...