题目链接:https://codeforces.com/contest/1367/problem/A 题意 给出一个字符串 $t$,找出原字符串 $s$,$t$ 由 $s$ 从左至右的所有长为 $2$ 的子串构成. 题解 只有 $s$ 的首尾字符会只在 $t$ 中出现一次,其余字符都会重复出现两次. 代码 #include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n =…
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #includ…
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/A Description You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "…
A. Short Program link http://codeforces.com/contest/878/problem/A describe Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language…
题目链接:http://codeforces.com/contest/879/problem/C C. Short Program time limit per test2 seconds memory limit per test256 megabytes Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and re…
C. Short Program time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and retur…
链接:http://codeforces.com/contest/550/problem/A 这是我第一次玩cf这种比赛,前面做了几场练习,觉得div2的前面几个还是比较水的. 所以看到这道题我果断觉得是拼手速的题啊,结果瞬间就一发WA,连pretest都没通过, 然后开始想,发现没那么简单的样子,很多坑的样子,当我写了2个循环把AB BA 都扫一遍时, 认为考虑周全后,觉得能过了,就交,过了pretest,当时看room里面 大多数还没过A呢,觉得很高兴. 然后学长说这题能叉很多人,我不懂什么…
A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB"…
题目链接:https://codeforces.com/contest/1367/problem/C 题意 给出一个长为 $n$ 的 $01$字符串,两个相邻 $1$ 间距应大于 $k$,初始序列合法,问最多能再使多少 $0$ 变为 $1$ . 题解 如果当前字符为 $0$,查找 $k$ 个距离内是否有 $1$: 若有则不合法,跳至最近的 $1$ 否则因为 $k$ 个距离内没有 $1$,当前字符置为 $1$,跳至第 $i + k$ 个字符 如果当前字符为 $1$,因为初始序列合法,下一个可以置为…
题目链接:https://codeforces.com/contest/1367/problem/B 题意 有一大小为 $n$ 的数组 $a$,问能否经过交换使所有元素与下标奇偶性相同(0 - indexed). 题解 奇偶性不同的奇数和偶数个数应相等. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int odd = 0, even = 0; for (int i…