做了四个题。。

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)的更多相关文章

  1. Educational Codeforces Round 51 (Rated for Div. 2) G. Distinctification(线段树合并 + 并查集)

    题意 给出一个长度为 \(n\) 序列 , 每个位置有 \(a_i , b_i\) 两个参数 , \(b_i\) 互不相同 ,你可以进行任意次如下的两种操作 : 若存在 \(j \not = i\) ...

  2. Educational Codeforces Round 51 (Rated for Div. 2) F - The Shortest Statement 倍增LCA + 最短路

    F - The Shortest Statement emmm, 比赛的时候没有想到如何利用非树边. 其实感觉很简单.. 对于一个询问答案分为两部分求: 第一部分:只经过树边,用倍增就能求出来啦. 第 ...

  3. Educational Codeforces Round 51 (Rated for Div. 2) The Shortest Statement

    题目链接:The Shortest Statement 今天又在群里看到一个同学问$n$个$n$条边,怎么查询两点直接最短路.看来这种题还挺常见的. 为什么最终答案要从42个点的最短路(到$x,y$) ...

  4. 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement

    [链接] 我是链接,点我呀:) [题意] [题解] 先处理出来任意一棵树. 然后把不是树上的边处理出来 对于每一条非树边的点(最多21*2个点) 在原图上,做dijkstra 这样就能处理出来这些非树 ...

  5. CodeForces Educational Codeforces Round 51 (Rated for Div. 2)

    A:Vasya And Password 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen(&q ...

  6. The Shortest Statement(Educational Codeforces Round 51 (Rated for Div.2)+最短路+LCA+最小生成树)

    题目链接 传送门 题面 题意 给你一张有\(n\)个点\(m\)条边的联通图(其中\(m\leq n+20)\),\(q\)次查询,每次询问\(u\)与\(v\)之间的最短路. 思路 由于边数最多只比 ...

  7. 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 ...

  8. 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 ...

  9. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

随机推荐

  1. [dp]编辑距离问题

    https://www.51nod.com/tutorial/course.html#!courseId=3 转移方程: 注意如何对齐的. 这个算法的特点是,S和T字符串左边始终是对齐的.为了更好地理 ...

  2. shell script-判断式

    test判断式 看下面: test -e /opt/a.txt && echo "exist" || echo "not exist" 判断 / ...

  3. Java虚拟机内存配置

    在做java开发时尤其是大型软件开发时经常会遇到内存溢出的问题,比如说OutOfMemoryError等.这是个让开发人员很痛苦.也很纠结的问题,因为我们有时不知道什么样的操作导致了这种问题的发生.所 ...

  4. spring framework 源码

    spring framework 各版本源码下载地址 现在spring的源码下载地址真是不好找,这次终于找到了.记录一下,以帮助需要的朋友. https://github.com/spring-pro ...

  5. Ocelot(五)- 流量限制、服务质量

    Ocelot(五)- 流量限制.服务质量 作者:markjiang7m2 原文地址:https://www.cnblogs.com/markjiang7m2/p/10965300.html 源码地址: ...

  6. JavaWeb:Cookie处理和Session跟踪

    JavaWeb:Cookie处理和Session跟踪 Cookie处理 什么是Cookie Cookie 是存储在客户端计算机上的文本文件,保留了各种跟踪信息.因为HTTP协议是无状态的,即服务器不知 ...

  7. ShardingJDBC(一)-转载

    Sharding-JDBC:垂直拆分怎么做? 原创: 尹吉欢 猿天地 今天 经过读写分离的优化后,小王可算是轻松了一段时间,读写分离具体的方案请查看这篇文章:Sharding-JDBC:查询量大如何优 ...

  8. POST和 GET

    http GET 和 POST 请求的优缺点.区别以及误区     Get和Post在面试中一般都会问到,一般的区别: (1)post更安全(不会作为url的一部分,不会被缓存.保存在服务器日志.以及 ...

  9. POJ1141Brackets Sequence 解题报告

    题目链接1 题目链接2 题目大意 给出一个括号序列,添加最少的括号使序列正确 解题思路 先将问题简单化,从求序列退化为求最小添加括号数的问题 用区间dp n³解决 f[l][r]表示使第l个到r个区间 ...

  10. Uva12174

    #include <bits/stdc++.h> using namespace std; ; int t; int s,n; ]; ]; ]; void init(){ memset(a ...