目录

A. YES or YES?

B. ICPC Balloons

C. Cypher

D. Double Strings


A. YES or YES?

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There is a string ss of length 33, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes" are all allowable.

Input

The first line of the input contains an integer tt (1≤t≤1031≤t≤103) — the number of testcases.

The description of each test consists of one line containing one string ss consisting of three characters. Each character of ss is either an uppercase or lowercase English letter.

Output

For each test case, output "YES" (without quotes) if ss satisfies the condition, and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).

Example

input

10
YES
yES
yes
Yes
YeS
Noo
orZ
yEz
Yas
XES

output

YES
YES
YES
YES
YES
NO
NO
NO
NO
NO
#include<bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){string s;cin>>s;int tmp1=0,tmp2=0,tmp3=0;for(int i=0;i<s.size();i++){if(s[0]=='Y'||s[0]=='y') tmp1++;if(s[1]=='E'||s[1]=='e') tmp2++;if(s[2]=='S'||s[2]=='s') tmp3++;}if(tmp1!=0&&tmp2!=0&&tmp3!=0)cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}

B. ICPC Balloons

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

In an ICPC contest, balloons are distributed as follows:

  • Whenever a team solves a problem, that team gets a balloon.
  • The first team to solve a problem gets an additional balloon.

A contest has 26 problems, labelled AA, BB, CC, ..., ZZ. You are given the order of solved problems in the contest, denoted as a string ss, where the ii-th character indicates that the problem sisi has been solved by some team. No team will solve the same problem twice.

Determine the total number of balloons that the teams recieved. Note that some problems may be solved by none of the teams.

Input

The first line of the input contains an integer tt (1≤t≤1001≤t≤100) — the number of testcases.

The first line of each test case contains an integer nn (1≤n≤501≤n≤50) — the length of the string.

The second line of each test case contains a string ss of length nn consisting of uppercase English letters, denoting the order of solved problems.

Output

For each test case, output a single integer — the total number of balloons that the teams received.

Example

input

6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES

output

5
2
6
7
8
17
#include<bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){int n;cin>>n;string s;cin>>s;set<char> st;for(int i=0;i<s.size();i++){st.insert(s[i]);}int tmp=st.size();cout<<tmp*2+n-st.size()<<endl;}return 0;
}

C. Cypher

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Luca has a cypher made up of a sequence of nn wheels, each with a digit aiai written on it. On the ii-th wheel, he made bibi moves. Each move is one of two types:

  • up move (denoted by UU): it increases the ii-th digit by 11. After applying the up move on 99, it becomes 00.
  • down move (denoted by DD): it decreases the ii-th digit by 11. After applying the down move on 00, it becomes 99.

Example for n=4n=4. The current sequence is 0 0 0 0.

Luca knows the final sequence of wheels and the moves for each wheel. Help him find the original sequence and crack the cypher.

Input

The first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1001≤n≤100) — the number of wheels.

The second line contains nn integers aiai (0≤ai≤90≤ai≤9) — the digit shown on the ii-th wheel after all moves have been performed.

Then nn lines follow, the ii-th of which contains the integer bibi (1≤bi≤101≤bi≤10) and bibi characters that are either UU or DD — the number of moves performed on the ii-th wheel, and the moves performed. UU and DD represent an up move and a down move respectively.

Output

For each test case, output nn space-separated digits  — the initial sequence of the cypher.

Example

input

3
3
9 3 1
3 DDD
4 UDUU
2 DU
2
0 9
9 DDDDDDDDD
9 UUUUUUUUU
5
0 5 9 8 3
10 UUUUUUUUUU
3 UUD
8 UUDUUDDD
10 UUDUUDUDDU
4 UUUU

output

2 1 1
9 0
0 4 9 6 9 
#include<bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}int j=0;while(n--){int b;string s;cin>>b>>s;for(int i=0;i<s.size();i++){if(s[i]=='D'){if(a[j]==9) a[j]=0;else  a[j]+=1;;} if(s[i]=='U'){if(a[j]==0) a[j]=9;else a[j]-=1;}}cout<<a[j]<<' ';j++;}cout<<endl;}return 0;
} 

D. Double Strings

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given nn strings s1,s2,…,sns1,s2,…,sn of length at most 88.

For each string sisi, determine if there exist two strings sjsj and sksk such that si=sj+sksi=sj+sk. That is, sisi is the concatenation of sjsj and sksk. Note that jj can be equal to kk.

Recall that the concatenation of strings ss and tt is s+t=s1s2…spt1t2…tqs+t=s1s2…spt1t2…tq, where pp and qq are the lengths of strings ss and tt respectively. For example, concatenation of "code" and "forces" is "codeforces".

Input

The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1051≤n≤105) — the number of strings.

Then nn lines follow, the ii-th of which contains non-empty string sisi of length at most 88, consisting of lowercase English letters. Among the given nn strings, there may be equal (duplicates).

The sum of nn over all test cases doesn't exceed 105105.

Output

For each test case, output a binary string of length nn. The ii-th bit should be 11 if there exist two strings sjsj and sksk where si=sj+sksi=sj+sk, and 00 otherwise. Note that jj can be equal to kk.

Example

input

3
5
abab
ab
abc
abacb
c
3
x
xx
xxx
8
codeforc
es
codes
cod
forc
forces
e
code

output

10100
011
10100101

思路:拆分字符串,判断拆分的字符串在不在已输入的字符里。

#include<bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){int n;cin>>n;string ans=""; //保存二进制结果vector<string> a(n);  //字符串数组map<string,int> mp;   // map标记for(int i=0;i<n;i++){cin>>a[i];mp[a[i]]=1; }for(int i=0;i<n;i++) //遍历字符串{string s="";int ok=0;for(int j=0;j<a[i].size();j++) //拆分字符串{s+=a[i][j];string c="";for(int k=j+1;k<a[i].size();k++) {c+=a[i][k];}if(mp.count(s)==1 && mp.count(c)==1) //判断在不在已标记的mp里面{ok=1;}}if(ok==1) ans+='1';else ans+='0';}cout<<ans<<endl;}return 0;
}

Codeforces Round #806 (Div. 4)题解相关推荐

  1. Codeforces Round #514 (Div. 2)题解

    Codeforces Round #514 (Div. 2)题解 A 喵,直接模拟. B 枚举所有盖章时的,合法的,左上角的位置.能盖的话就盖一下.最后check一下图案是否相等即可 C 一轮一轮的扔 ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. 【算法题解】Codeforces Round #817 (Div. 4)题解

    文章目录 Codeforces Round #817 (Div. 4)题解 A. Spell Check B. Colourblindness C. Word Game D. Line E. Coun ...

  4. Codeforces Round #747 (Div. 2)题解

    Codeforces Round #747 (Div. 2)题解 (本博客将持续更新以后每场CF div2的题解,喜欢ACM.OI的小伙伴记得点个关注哟) 昨天夜晚刷网络流刷入迷了,渐渐就忘记了我还要 ...

  5. Codeforces Round #789 (Div. 2)题解

    Codeforces Round #789 (Div. 2)题解 A. Tokitsukaze and All Zero Sequence 原题链接 算法标签 贪心 排序 思路 情况一:数组存在零 → ...

  6. Codeforces Round #748 (Div. 3) 题解 完整A~G

    Codeforces Round #748 (Div. 3) 题解 A. Elections 题意 已知竞选中三个候选人的当前得票数 a , b , c a,b,c a,b,c,现在可以增加任何一个人 ...

  7. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

  8. Codeforces Round #734 (Div. 3) 题解

    Hello大家好,今天给大家带来的是 Codeforces Round #734 (Div. 3) 的全题目讲解. 本文链接:https://www.lanqiao.cn/questions/2040 ...

  9. Codeforces Round #462 (Div. 2)题解

    Codeforces Round #462 (Div. 2) B题--我固执的认为1e18是18位数,导致被hack,花了20分钟才检查出这个错误,很僵硬 Codeforces 934C 题意 给定一 ...

最新文章

  1. 重庆商务学校有计算机专业吗,重庆对外经贸学院计算机科学与技术专业
  2. 27岁华裔小伙一战成名!搞出美国新冠最准预测模型,一人干翻专业机构,彭博:Superstar...
  3. JSPatch defineProtocol 实现详解
  4. python 银行业务系统程序编程写_python多线程实现代码(模拟银行服务操作流程)
  5. jdbc mysql myeclipse_关于JDBC连接MySQL的问题,我一直解决不了(Myeclipse 环境下)
  6. vue 秒转换为时分秒_三年级数学上册时分秒换算口诀(附重点习题)
  7. 基于AE+C#读取文件及图层输出
  8. 航模飞机设计基础知识
  9. linux远程桌面rdesktop,Linux下通过rdesktop连接Windows远程桌面
  10. 3 步理清 Python 数据分析关键点,新手必看
  11. js 根据公历日期 算出农历_利用Javascript获取当前日期的农历日期
  12. dis的前缀单词有哪些_三个常见的前缀,re-,anti-,dis-,你知道它们的用法吗?
  13. 使用JBE(Java Bytecode Editor)修改Java字节码
  14. 这些好看的皮肤,这不嗖的一下,统统都到电脑里了~
  15. jQuery-动画效果(王者荣耀手风琴案例)
  16. C语言等待一秒,延时函数sleep()
  17. 蜻蜓特派员 Windows XP SP3 纯净终结版
  18. HDOJ 5128 The E-pang Palace
  19. 数据资产管理实践白皮书(6.0版)解读
  20. 使用DLL引起的error LNK2019: 无法解析的外部符号

热门文章

  1. php用360浏览器显示不正常,win10系统下360浏览器网页显示不正常的解决方法
  2. 数据结构(数组)的特点以及优缺点
  3. 云队友丨7年估值2000亿,产业互联网的底层逻辑
  4. Twitter整合营销的方法技巧
  5. 一场中国顶级赛事掀起的浪潮:AI人才,应该这么培养!
  6. DotCMS中文教程
  7. 2017年由Unity员工打造的最爱
  8. Redis6在Liunx系统下的安装、启动和关闭
  9. 以300亿美元收购塞纳,甲骨文为何这么迫切?
  10. 诺基亚7.2 刷入第三方ROM