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< ...
随机推荐
- ssh动态转发小记
ssh,一般常用来做远程登录管理,也就是连上远程机器,得到一个shell,然后交互式地在上面敲命令-看结果-再敲命令. 偶尔也会用在脚本里,做些自动化批处理上传下载的操作,但本质上也是用shell来执 ...
- 《精通Spring4.X企业应用开发实战》读后感第六章(使用外部属性文件)
- springboot 使用war包部署
ps://www.cnblogs.com/jiaoyiping/p/4251718.html
- Hadoop WordCount单词计数原理
计算文件中出现每个单词的频数 输入结果按照字母顺序进行排序 编写WordCount.java 包含Mapper类和Reducer类 编译WordCount.java javac -classpath ...
- [笔记]解决git本地仓库不能上传到gitee远程仓库的问题
关键词:git.gitee.码云.上传远程仓库失败 1.gitee有一个远程仓库名字是CommandModel,里面只有两个README文件 2.假如我目录 D:\eclipse\workspace ...
- Scrapy 框架进阶笔记
上一篇简单了解了scrapy各个模块的功能:Scrapy框架初探 -- Dapianzi卡夫卡 在这篇通过一些实例来深入理解 scrapy 的各个对象以及它们是怎么相互协作的 settings.py ...
- Python 爬虫笔记
urllib python3 与 python2 的urllib很不一样,之前urllib2的方法基本上都变成了python3里的urllib.request模块中 import urllib.req ...
- C#中参数值传递和址传递
概论 我认为的形参和实参是这样的,形参是形式上的参量,和"抽象类"的概念差不多,不是实际存在的.不用的时候不占用内存,被调用的时候分配内存,调用结束,释放内存.类似于"抽 ...
- oracle例程
原创转载请注明出处 启动例程: 数据库启动例程的3个步骤 启动例程(NOMOUNT状态):读取参数文件,分配SGA和启动后台进程. 装载数据库(MOUNT状态):根据初始化参数control_file ...
- 开发外包注意事项二——iOS APP的开发
目前我的方式是按时间算. 首先这得建立在双方的信任基础上. 以我做过的Case为例: 首先会和客户一起评估需求: 1. 哪些功能是最为重要的 2. 哪些功能是可以删除的 3. 用什么策略保证APP的出 ...