最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛

A. Bark to Unlock
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.

Mu-mu's enemy Kashtanka wants to unlock Mu-mu's phone to steal some sensible information, but it can only bark n distinct words, each of which can be represented as a string of two lowercase English letters. Kashtanka wants to bark several words (not necessarily distinct) one after another to pronounce a string containing the password as a substring. Tell if it's possible to unlock the phone in this way, or not.

Input

The first line contains two lowercase English letters — the password on the phone.

The second line contains single integer n (1 ≤ n ≤ 100) — the number of words Kashtanka knows.

The next n lines contain two lowercase English letters each, representing the words Kashtanka knows. The words are guaranteed to be distinct.

Output

Print "YES" if Kashtanka can bark several words in a line forming a string containing the password, and "NO" otherwise.

You can print each letter in arbitrary case (upper or lower).

Examples
input
ya
4
ah
oy
to
ha
output
YES
input
hp
2
ht
tp
output
NO
input
ah
1
ha
output
YES
Note

In the first example the password is "ya", and Kashtanka can bark "oy" and then "ah", and then "ha" to form the string "oyahha" which contains the password. So, the answer is "YES".

In the second example Kashtanka can't produce a string containing password as a substring. Note that it can bark "ht" and then "tp" producing "http", but it doesn't contain the password "hp" as a substring.

In the third example the string "hahahaha" contains "ah" as a substring.

这个题就是暴力,要不s是p的子串,要不存在两个字符串可以拼成s,因为长度都是2,直接暴力枚举啊

#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int n;
scanf("%d",&n);
string q[];
for (int i=; i<n; i++)
cin>>q[i];
for (int i=; i<n; i++)
{
if(q[i]==s)return *puts("YES");
for (int j=; j<n; j++)
if (q[i][]==s[]&&q[j][]==s[])return *puts("YES");
}
puts("NO");
return ;
}
B. Race Against Time
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.

The entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time h hours, m minutes, s seconds.

Last time Misha talked with the coordinator at t1 o'clock, so now he stands on the number t1 on the clock face. The contest should be ready by t2 o'clock. In the terms of paradox it means that Misha has to go to number t2 somehow. Note that he doesn't have to move forward only: in these circumstances time has no direction.

Clock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).

Given the hands' positions, t1, and t2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t1 to t2 by the clock face.

Input

Five integers hmst1, t2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t1, t2 ≤ 12, t1 ≠ t2).

Misha's position and the target time do not coincide with the position of any hand.

Output

Print "YES" (quotes for clarity), if Misha can prepare the contest on time, and "NO" otherwise.

You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

Examples
input
12 30 45 3 11
output
NO
input
12 0 1 12 1
output
YES
input
3 47 0 4 9
output
YES
Note

The three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same.

给你一个时间,将其视为钟面,指针将其划分为许多区域,再读入两个时刻,问这两个时刻是否在同一个区域内,暴力模拟角度,不过这个题目可能直接int更优雅些。完全不会有精度问题
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a[];
int t1,t2;
scanf("%lf%lf%lf%d%d",&a[],&a[],&a[],&t1,&t2);
t1*=,t2*=;
a[]+=a[]/.;
a[]+=a[]/.;
a[]*=;
if(a[]>)a[]-=.;
sort(a,a+);
int tt1=,tt2=;
if(a[]<t1&&t1<a[])tt1=;
else if(a[]<t1&&t1<a[])tt1=;
if(a[]<t2&&t2<a[])tt2=;
else if(a[]<t2&&t2<a[])tt2=;
if(tt1==tt2)puts("YES");
else puts("NO");
return ;
}
C. Qualification Rounds
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset.

k experienced teams are participating in the contest. Some of these teams already know some of the problems. To make the contest interesting for them, each of the teams should know at most half of the selected problems.

Determine if Snark and Philip can make an interesting problemset!

Input

The first line contains two integers nk (1 ≤ n ≤ 105, 1 ≤ k ≤ 4) — the number of problems and the number of experienced teams.

Each of the next n lines contains k integers, each equal to 0 or 1. The j-th number in the i-th line is 1 if j-th team knows i-th problem and 0 otherwise.

Output

Print "YES" (quotes for clarity), if it is possible to make an interesting problemset, and "NO" otherwise.

You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

Examples
input
5 3
1 0 1
1 1 0
1 0 0
1 0 0
1 0 0
output
NO
input
3 2
1 0
1 1
0 1
output
YES
Note

In the first example you can't make any interesting problemset, because the first team knows all problems.

In the second example you can choose the first and the third problems.

暴力二进制模拟下就好的,这样复杂度是够的

#include <bits/stdc++.h>
using namespace std;
int vis[];
int main()
{
int n,k;
cin>>n>>k;
memset(vis,,sizeof(vis));
for(int i=; i<n; i++)
{
int ans=;
for(int j=; j<k; j++)
{
int a;
cin>>a;
ans=ans*+a;
}
vis[ans]++;
}
for(int i=; i<(<<k); i++)
for(int j=; j<(<<k); j++)
if(vis[i]>&&vis[j]>&&((i&j)==))
{
cout<<"YES"<<endl;
return ;
}
cout<<"NO"<<endl;
return ;
}

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

  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 combined)

    A. Bark to Unlock 题目链接:http://codeforces.com/contest/868/problem/A 题目意思:密码是两个字符组成的,现在你有n个由两个字符组成的字符串 ...

  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. SpringBoot学习笔记-Chapter2(hello word)

    开篇 第一次在博客园上写博客,初衷是想记录一下学习笔记,以往都是用笔去记录下学习笔记,现在来看在效率.检索速度上以及可可复制性都不好.作为一名Java开发人员 不会Spring Boot一定会被鄙视的 ...

  2. 使用vscode软件运行zebrajs框架小结

    最近在研究使用zebrajs框架,用vscode编辑器进行开发.vsc这个编辑器说起来还是很强大的,就是支持各种系统的多种语言开发.用于前端的话可以直接在编辑器上边调试javascript,就是需要n ...

  3. PeopleSoft FSCM Production Support 案例分析之一重大紧急事故发生时的应对策略

    案例背景: 今天一大早用户打电话来讲昨天上传的银行的forex payment return file好像没有被处理到,我一听就觉得纳闷,因为昨天晚上operator也没有给我打电话啊(如果有job ...

  4. lsattr

    -a  将隐藏文件的属性也显示出来 -R 连同子目录的数据也一并列出来 chattr +aij 文件名

  5. 使用python模拟cookie登陆wooyun

    import urllib2 class SimpleCookieHandler(urllib2.BaseHandler): def http_request(self, req): simple_c ...

  6. (五)VMware Harbor 部署之SSL

    转自:https://www.cnblogs.com/Rcsec/p/8479728.html 1 .签名证书与自签名证书 签名证书:由权威颁发机构颁发给服务器或者个人用于证明自己身份的东西. 自签名 ...

  7. Use-After-Free

    0x00 UAF利用原理 uaf漏洞产生的主要原因是释放了一个堆块后,并没有将该指针置为NULL,这样导致该指针处于悬空的状态(这个指针可以称为恶性迷途指针),同样被释放的内存如果被恶意构造数据,就有 ...

  8. Java中集合类

    一.Collection Collection 接口用于表示任何对象或元素组.想要尽可能以常规方式处理一组元素时,就使用这一接口.Collection 在前面的大图也可以看出,它是List 和 Set ...

  9. bootstrap 按钮组的嵌套

    您可以在一个按钮组内嵌套另一个按钮组,即,在一个 .btn-group 内嵌套另一个 .btn-group .当您想让下拉菜单与一系列按钮组合使用时,就会用到这个. 实例: <!DOCTYPE ...

  10. shell脚本,通过传参求斐波那契数列如(0,1,1,2,3,5,8,13..........)

    [root@localhost wyb]# cat fibo.sh #!/bin/bash #斐波那契数列 ,,,,,,, > file >> file count=$ for i ...