Educational Codeforces Round 51 (Rated for Div. 2)
做了四个题。。
A. Vasya And Password
直接特判即可,,为啥泥萌都说难写,,,,
这个子串实际上是忽悠人的,因为每次改一个字符就可以
我靠我居然被hack了????
%……&*()(*&……好吧我把$0$从数字里扔了。
/* */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int T;
char s[MAXN];
void solve() {
int N = strlen(s + );
int a = , b = , c = ;
for(int i = ; i <= N; i++) {
if(s[i] >= '' && s[i] <= '') a++;
if(s[i] >= 'a' && s[i] <= 'z') b++;
if(s[i] >= 'A' && s[i] <= 'Z') c++;
}
if(a == ) {
if(b > ) {
for(int i = ; i <= N; i++)
if(s[i] >= 'a' && s[i] <= 'z') {s[i] = ''; break;}
b--;
} else if(c > ) {
for(int i = ; i <= N; i++)
if(s[i] >= 'A' && s[i] <= 'Z') {s[i] = ''; break;}
c--;
}
}
if(b == ) {
if(a > ) {
for(int i = ; i <= N; i++)
if(s[i] >= '' && s[i] <= '') {s[i] = 'a'; break;}
a--;
} else if(c > ) {
for(int i = ; i <= N; i++)
if(s[i] >= 'A' && s[i] <= 'Z') {s[i] = 'a'; break;}
c--;
}
}
if(c == ) {
if(a > ) {
for(int i = ; i <= N; i++)
if(s[i] >= '' && s[i] <= '') {s[i] = 'A'; break;}
a--;
} else if(b > ) {
for(int i = ; i <= N; i++)
if(s[i] >= 'a' && s[i] <= 'z') {s[i] = 'A'; break;}
b--;
}
}
printf("%s\n", s + );
}
main() {
T = read();
while(T--) {
scanf("%s", s + );
solve();
}
return ;
}
/*
2 2 1
1 1
2 1 1
*/
A
B. Relatively Prime Pairs
很显然,$i$和$i+1$是互质的。
做完了
/* */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int l, r;
main() {
l = read(), r = read();
if(l == r) {puts("NO"); return ;}
puts("YES");
for(int i = l; i <= r - ; i += ) {
cout << i << " " << i + << endl;
}
return ;
}
/*
2 2 1
1 1
2 1 1
*/
B
C. Vasya and Multisets
显然,如果有偶数个优秀的,对半分就可以
如果有奇数个,直接拿出一个$\geqslant 3$的数加到小的里面
否则无解
/* */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar();
int x = , f = ;
while(c < '' || c > '') {
if(c == '-') f = -;c = getchar();}while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, A[MAXN], timssssss[MAXN];
main() {
int n=read();
for(int i = ; i <= n; ++i) ++timssssss[A[i] = read()];
int cnt[] = {,,,,};
for(int i = ; i <= ; ++i)
if(timssssss[A[i]] < ) ++cnt[timssssss[A[i]]];
else ++cnt[];
if(cnt[] & && cnt[] == ) return puts("NO"),;
puts("YES");
int mid = cnt[]>>;
if(cnt[]&) {
int p = ;
for(int i = ; i <= n; ++i)
if(timssssss[A[i]] > ) {
p = i;
break;
}
for(int i = ; i <= n; ++i)
if(timssssss[A[i]] == ) {
if(mid) putchar('A'), --mid;
else putchar('B');
} else if(i != p) putchar('B');
else putchar('A');
} else {
for(int i = ; i <= n; ++i)
if(timssssss[A[i]] == ) {
if(mid) putchar('A'), --mid;
else putchar('B');
} else putchar('B');
}
return ;
}
/*
2 2 1
1 1
2 1 1
*/
C
D. Bicolorings
普及dp??。。。
因为只有两行,考虑把列的状态记下来
$f[i][j][sta]$表示到第$i$列,有$j$个连通块的方案,当前列的状态为$sta$,就是“白白” “白黑”“黑白”“黑黑”这四种状态
转移的时候枚举上一行选了啥
/* */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = ;
const double eps = 1e-;
inline int read() {
char c = getchar();
int x = , f = ;
while(c < '' || c > '') {
if(c == '-') f = -;c = getchar();}while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, K;
int f[][][];
// 0 �װ�
// 1 ��
// 2 �ڰ�
// 3 �ں�
main() {
N = read(); K = read();
f[][][] = ;
f[][][] = ;
f[][][] = ;
f[][][] = ;
for(int i = ; i <= N; i++) {//��i���
for(int j = ; j <= K; j++) {//��j���� (f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j - ][]) %= mod; (f[i][j][] += f[i - ][j - ][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j - ][]) %= mod;
(f[i][j][] += f[i - ][j - ][]) %= mod; (f[i][j][] += f[i - ][j - ][]) %= mod;
(f[i][j][] += f[i - ][j - ][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j - ][]) %= mod; (f[i][j][] += f[i - ][j - ][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
(f[i][j][] += f[i - ][j][]) %= mod;
//for(int k = 0; k <= 3; k++)//��ǰ״̬ }
}
int ans = (f[N][K][] + f[N][K][] % mod + f[N][K][] % mod + f[N][K][] % mod) % mod;
cout << ans;
return ;
}
/*
2 2 1
1 1
2 1 1
*/
D
F. The Shortest Statement
https://www.cnblogs.com/zwfymqz/p/9688315.html
Educational Codeforces Round 51 (Rated for Div. 2)的更多相关文章
- Educational Codeforces Round 51 (Rated for Div. 2) G. Distinctification(线段树合并 + 并查集)
题意 给出一个长度为 \(n\) 序列 , 每个位置有 \(a_i , b_i\) 两个参数 , \(b_i\) 互不相同 ,你可以进行任意次如下的两种操作 : 若存在 \(j \not = i\) ...
- Educational Codeforces Round 51 (Rated for Div. 2) F - The Shortest Statement 倍增LCA + 最短路
F - The Shortest Statement emmm, 比赛的时候没有想到如何利用非树边. 其实感觉很简单.. 对于一个询问答案分为两部分求: 第一部分:只经过树边,用倍增就能求出来啦. 第 ...
- Educational Codeforces Round 51 (Rated for Div. 2) The Shortest Statement
题目链接:The Shortest Statement 今天又在群里看到一个同学问$n$个$n$条边,怎么查询两点直接最短路.看来这种题还挺常见的. 为什么最终答案要从42个点的最短路(到$x,y$) ...
- 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement
[链接] 我是链接,点我呀:) [题意] [题解] 先处理出来任意一棵树. 然后把不是树上的边处理出来 对于每一条非树边的点(最多21*2个点) 在原图上,做dijkstra 这样就能处理出来这些非树 ...
- CodeForces Educational Codeforces Round 51 (Rated for Div. 2)
A:Vasya And Password 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen(&q ...
- The Shortest Statement(Educational Codeforces Round 51 (Rated for Div.2)+最短路+LCA+最小生成树)
题目链接 传送门 题面 题意 给你一张有\(n\)个点\(m\)条边的联通图(其中\(m\leq n+20)\),\(q\)次查询,每次询问\(u\)与\(v\)之间的最短路. 思路 由于边数最多只比 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
随机推荐
- mongodb插入时间
插入时间: db.test.insert({time:new Date()}) 给mongodb插入日期格式的数据时发现,日期时间相差8个小时,原来存储在mongodb中的时间是标准时间UTC +0: ...
- ARC097C K-th Substring
传送门 题目 You are given a string s. Among the different substrings of s, print the K-th lexicographical ...
- 项目中gulp使用发生的错误及解决
在项目开发中,执行gulp css来生成合成的css文件时,报如下错误 Error: Cannot find module 'browserslist' 解决方法: npm install brows ...
- 1.如何绕过WAF(Web应用防火墙)
一:大小写转换法: 看字面就知道是什么意思了,就是把大写的小写,小写的大写.比如: SQL:sEleCt vERsIoN(); XSS:)</script> 出现原因:在waf里,使用 ...
- hdu1071
#include <iostream> #include <stdio.h> using namespace std; int main() { int t; double x ...
- JQuery获取body的大小
$('body').height(); $('body').width();
- 清北刷题冲刺 10-31 p.m
数列 #include<iostream> #include<cstdio> using namespace std; long long a,b,ans; void f(lo ...
- vue-cli 使用sass(scss)
安装依赖: npm install sass-loader node-sass vue-style-loader --save-dev
- PDO中构建事务处理的应用程序
<meta http-equiv="Content-Type" content="text/html";charse="utf-8" ...
- 装饰器(Decorator)模式
public interface IDoThings { public void doSomeThing(); } public class DoThings implements IDoThings ...