Codeforces Round #438
来源:互联网 发布:c语言标识符可分为 编辑:程序博客网 时间:2024/06/05 06:35
A
模拟,两种情况
① 一种是情况1,要查找的单词和某个片段重合
② 另一种是 情况2,要查找的单词和另一个单词相反。
或者 查找的单词 由两个单词构成
#include <bits/stdc++.h>using namespace std;/* 第一个单词再后面 第二个单词再前面。*/string s;string w;int m;int main(){ while(cin>>s){ cin>>m; bool flag=false; bool sum1=false; bool sum2=false; for(int i=0;i<m;i++){ cin>>w; if(s[0]==w[1]) sum1=true; if(s[1]==w[0]){ sum2=true; } if(s[0]==w[0]&&s[1]==w[1]) flag=true; } if(flag){ puts("yes"); } else{ if(sum1&&sum2) puts("yes"); else puts("no"); } } return 0;}
B 这道题是试出来的。如果开头有指针那么就走不了,如果终点有没事。。
把所有可能出现60的地方全mod60.
#include <bits/stdc++.h>using namespace std;int vis[70];int h,s,t,t1,t2;int main(){ while(cin>>h>>s>>t>>t1>>t2){ memset(vis,0,sizeof(vis)); if(h==0) {vis[0]+=1;} else vis[(h*5)%60]=true; vis[s%60]+=1; vis[t%60]+=1; if(t1>t2){ swap(t1,t2); } bool flag=false; t1=(t1*5)%60; t2=(t2*5)%60;; int tim=(t1)%60; int sum=0; while(1){ if(tim==t2) {flag=true;break;} if(vis[tim]) { //cout<<tim<<endl; sum+=vis[tim]; } tim=(tim+1)%60; } if(sum==0||sum==3) puts("yes"); else puts("no"); } return 0;}
C没啥具体的思路。。
发现如果在答案的集合如果大于2,那么一定可以从中找到两个满足条件。即最小的答案一定可以是两个。
证明也没看懂。。
遇到这种题就大胆的试把。。
#include <bits/stdc++.h>using namespace std;const int maxn = 1e5+10;/**/bool vis[16];int main(){ int m,n; while(~scanf("%d%d",&m,&n)){ bool flag=false; memset(vis,false,sizeof(vis)); for(int i=0;i<m;i++){ int num=0; int x=0; int a; for(int j=1;j<=n;j++){ scanf("%d",&a); if(a){ num++; x|=1<<(j-1); } } vis[x]=true; } if(vis[0]) flag=true; for(int i=0;i<16&&!flag;i++){ for(int j=0;j<16&&!flag;j++){ if(vis[i]&&vis[j]&&!(i&j)&&i!=j) flag=true; } } if(flag) puts("yes"); else puts("no"); } return 0;}
阅读全文
0 0
- Codeforces Round #438 题解
- Codeforces Round #438 题解
- Codeforces Round #438 B
- Codeforces Round #438
- Codeforces Round #438
- Codeforces Round #438
- Codeforces Round #438
- 【codeforces】Codeforces Round #363
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 868A/B/C
- Codeforces Round #438 C. Qualification Rounds 二进制
- Codeforces Round #438 A. Bark to Unlock
- Codeforces Round #438 B. Race Against Time
- codeforces round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 题解
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #270 Codeforces Round #270
- 【Codeforces】Codeforces Round #271 div2
- ccs的三种颜色格式
- sdut 2136 数据结构实验之二叉树的建立与遍历
- Atcoder arc 084 C
- 项目管理学习总结(10)——项目经理需要具备8点管理素质
- 第二章:reactNative开发中模拟器的配置
- Codeforces Round #438
- 天梯地图(30 分)
- leetcode problem solve 2——Add Two Numbers
- [JZOJ5454]仔细的检查
- Python高级编程-如何让字典保持有序?
- loj #6062. 「2017 山东一轮集训 Day2」Pair(线段树)
- android开发之路(1)
- python猜数字
- bfs:一维坐标的移动