这是一场三人组队赛来的,单人带电子模板不限时单挑试一下。按照难度排序。
B - Balls of Buma
题意:玩祖玛,射入任意颜色的球一个,当某段长度变长了且长度变长后>=3则这段就会消除,问把所有的球只用一次射击就消除的方法是多少?
题解:看起来一定要两边对称。
int n;
char s[300005];
int L[300005], R[300005], top;
void test_case() {
top = 0;
L[++top] = 1;
R[top] = 1;
for(int i = 2; i <= n; ++i) {
if(s[i] == s[R[top]])
R[top] = i;
else {
L[++top] = i;
R[top] = i;
}
}
if(!(top & 1)) {
puts("0");
return;
}
int mid = (top + 1) / 2;
if(R[mid] == L[mid]) {
puts("0");
return;
}
for(int i = 1; i < mid; ++i) {
if(s[R[mid - i]] != s[L[mid + i]]) {
puts("0");
return;
} else {
if(R[mid - i] - L[mid - i] + 1 + R[mid + i] - L[mid + i] + 1 < 3) {
puts("0");
return;
}
}
}
printf("%d\n", R[mid] - L[mid] + 1 + 1);
}
int main() {
#ifdef KisekiPurin
freopen("KisekiPurin.in", "r", stdin);
#endif // KisekiPurin
while(1) {
n = reads(s + 1);
test_case();
}
}
L - Lexicography
题意:给n*l个字母,构造n个长为l的字符串,使得第k个字符串最小。
题解:?
int n, l, k;
char s[1000005];
void test_case() {
sort(s + 1, s + 1 + n * l);
int cur = l + 1;
for(int i = 1; i < k; ++i) {
for(int j = 1; j <= l; ++j) {
putchar(s[cur]);
++cur;
}
putchar('\n');
}
for(int j = 1; j <= l; ++j)
putchar(s[j]);
putchar('\n');
for(int i = k + 1; i <= n; ++i) {
for(int j = 1; j <= l; ++j) {
putchar(s[cur]);
++cur;
}
putchar('\n');
}
}
int main() {
#ifdef KisekiPurin
freopen("KisekiPurin.in", "r", stdin);
#endif // KisekiPurin
while(1) {
read(n), read(l), read(k);
reads(s + 1);
//puts(s + 1);
test_case();
}
}