目录
A. Deletions of Two Adjacent Letters
C. Weight of the System of Nested Segments
杂谈
Div.3的题还是做着比较顺的,D题AC之后直接睡觉去了(第二天还要早八╯︿╰)
前两题签得还是比较顺利的(没有像上一场的B分类分崩了),C题读题和样例卡了很久,在我反应过来题意和样例输出的意思的时候,它发通知解释输出的意思了......然后D题调数组下标问题的过程真的非常痛苦,好在最后调完一遍过了,提前收工睡觉。
A. Deletions of Two Adjacent Letters
题目大意:给定一个字符串s和一个字符c,每次可以删除字符串中两个相邻的字符,问能否将字符串进行如上操作使得最终仅剩一个字符c。
解题思路:要想剩下一个字符,那么剩下的这个字符的左右边必须有偶数个字符,由于题目保证字符串长度为奇数,因此只要遍历一遍字符串,存在一个字符c出现的位置是奇数位置,那么就可以满足要求,否则不行。
AC代码:
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define mid (l + r >> 1)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
int main(){
//freopen("input.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while(t--){
string s;
cin >> s;
char c;
cin >> c;
int len = s.size();
int flag = 0;
for(int i = 0; i < len; i++){
if(s[i] == c && i % 2 == 0){
flag = 1;
break;
}
}
if(flag) cout << "YES" << endl;
else cout << "NO"