A
答:是还是是?每次测试的时间限制1 秒每次测试的内存限制为 256 MB输入标准输入输出标准输出有一个字符串ss长度33,由大写和小写英文字母组成。检查它是否等于“YES”(不带引号),其中每个字母在任何情况下都可以。例如,“yES”、“是”、“是”都是允许的。
输入输入的第一行包含一个整数tt (1≤吨≤1031≤t≤103) — 测试用例的数量。
每个测试的描述由一行包含一个字符串组成ss由三个字符组成。每个字符ss是大写或小写的英文字母。
输出对于每个测试用例,输出“YES”(不带引号),如果ss满足条件,否则为“NO”(不带引号)。
在任何情况下都可以输出“YES”和“NO”(例如,字符串“yES”,“yes”和“Yes”将被识别为肯定响应)。
例输入复制10 YES yES yes Yes YeS Noo orZ yEz Yas XES
输出复制YES YES YES YES YES NO NO NO NO NO
注意前五个测试用例包含字符串“YES”,“yES”,“yes”,“Yes”,“YeS”。所有这些都等于“YES”,其中每个字符要么是大写的,要么是小写的。
#include<bits/stdc++.h>
using namespace std;
char a[3];
int main(){
int _;
cin>>_;
while(_--){
for(int i = 1;i<=3;i++) cin>>a[i];
if((a[1]=='y'||a[1]=='Y')&&(a[2]=='e'||a[2]=='E')&&(a[3]=='s'||a[3]=='S')){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
return 0;
}
B
B. ICPC气球每次测试的时间限制1 秒每次测试的内存限制为 256 MB输入标准输入输出标准输出在ICPC比赛中,气球的分布如下:
A contest has 26 problems, labelled A一个, BB, CC, ..., ZZ. You are given the order of solved problems in the contest, denoted as a string ss, where the i我-th character indicates that the problem sisi has been solved by some team. No team will solve the same problem twice.
- 每当一个团队解决问题时,这个团队就会得到一个气球。
- 第一个解决问题的团队会得到一个额外的气球。
确定团队收到的气球总数。请注意,有些问题可能不是由任何团队解决的。
输入The first line of the input contains an integer tt (1≤t≤1001≤吨≤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.
输出对于每个测试用例,输出一个整数 — 团队收到的气球总数。
例输入复制6 3 ABA 1 A 3 ORZ 5 BAAAA 4 BKPT 10 CODEFORCES
输出复制5 2 6 7 8 17
注意In the first test case, 55 balloons are given out:
发放的气球总数为2+2+1=52+2+1=5.
- Problem A一个 is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem A一个.
- Problem BB is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem BB.
- Problem A一个 is solved. That team receives only 11 气球,因为他们解决了问题。请注意,他们不会得到额外的气球,因为他们不是 第一个解决问题的团队 A一个.
在第二个测试用例中,只有一个问题解决了。解决它的团队收到22气球:一个是因为他们解决了问题,一个是额外的气球,因为他们是第一个解决问题的团队A一个.
#include<bits/stdc++.h>
using namespace std;
int main(){
int _;
cin>>_;
while(_--){
int ans = 0;
int n;
cin>>n;
string s;
int a[50] = {0};
cin>>s;
for(int i = 0;i<n;i++){
a[s[i]-'A']++;
}
for(int i = 0;i<26;i++){
if(a[i]==1){
ans+=2;
}
if(a[i]>1){
ans = ans+2+a[i]-1;
}
//cout<<ans<<"\t";
}
cout<<ans<<endl;
}
return 0;
}
C
C. 密码每次测试的时间限制1 秒每次测试的内存限制为 256 MB输入标准输入输出标准输出卢卡有一个由一个序列组成的密码nn车轮,每个车轮都有一个数字一个我ai写在上面。在我我-第轮,他做了b我bi移动。每个移动是以下两种类型之一:
- 向上移动(表示为UU):它增加了我我-第 1 位数字11.应用上移后继续99,它变成了00.
- 向下移动(表示为DD):它减少了我我-第 1 位数字11.应用后向下移动00,它变成了99.
示例n=4n=4.当前序列为 0 0 0 0 0。
卢卡知道车轮的最终顺序和每个车轮的移动。帮助他找到原始序列并破解密码。
输入第一行包含单个整数tt (1≤吨≤1001≤吨≤100) — 测试用例的数量。
每个测试用例的第一行包含单个整数nn (1≤n≤1001≤n≤100) — 车轮数量。
第二行包含nn整数一个我ai (0≤一个我≤90≤ai≤9) — 显示在我我-第 0 个轮子后执行所有移动。
然后nn线条跟随,我我其中 -th 包含整数b我bi (1≤b我≤101≤bi≤10) 和b我bi字符UU或DD— 在 上执行的移动次数我我-th 轮子,并执行了移动。UU和DD分别表示向上移动和向下移动。
输出对于每个测试用例,输出nn空格分隔的数字 — 密码的初始序列。
例输入复制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
输出复制2 1 1 9 0 0 4 9 6 9
注意在第一个测试用例中,我们可以证明初始序列是[2,1,1][2,1,1].在这种情况下,执行了以下移动:
最后一个序列是[9,3,1][9,3,1],它与输入匹配。
- 在第一个轮子上:2→D1→D0→D92→D1→D0→D9.
- 在第二个轮子上:1→U2→D1→U2→U31→U2→D1→U2→U3.
- 在第三个轮子上:1→D0→U11→D0→U1.
#include <bits/stdc++.h>
using namespace std;
void ok() {
int x;
cin >> x;
vector<int> v(x + 1);
for(int i = 1; i <= x; i ++) {
cin >> v[i];
}
for(int i = 1; i <= x; i ++) {
int m; string s;
cin >> m >> s;
for(int j = 0; j < m; j++) {
if(s[j] == 'D') {
v[i] ++;
if(v[i] == 10)
v[i] = 0;
} else {
v[i] --;
if(v[i] == -1)
v[i] = 9;
}
}
}
for(int i = 1; i <= x; i ++) {
cout << v[i] << ' ';
}
cout << endl;
}
int main() {
int _;
cin >> _;
while(_ --) {
ok();
}
return 0;
}