做了四个题。。

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. 【机器学习】分类器组合——AdaBoost

    AdaBoost是一种迭代算法,其核心思想是针对同一个训练集训练不同的分类器(弱分类器),然后把这些弱分类器集合起来,构成一个更强的最终分类器(强分类器). AdaBoost其实只是boost的一个特 ...

  2. 第六课 ROS的空间描述和变换

    1.空间描述与变换 有两个坐标系A和B,B坐标系中有一个点P,如何把B坐标系中的P映射到A坐标系呢,这就涉及到空间描述与变换, 先看一下旋转矩阵: 上面中间的行向量中的元素表示在B坐标系当中的元素用A ...

  3. Gulp的学习和使用

    Gulp是一种直观.自动化构建的工具. Gulp是基于Node和NPM,安装教程点这里. 什么是Gulp? Gulp使用了node.js的流控制系统,使其(Gulp)构建更快,因为它不需要将临时文件/ ...

  4. URAL 2018 The Debut Album (DP)

    题意:给出n长度的数列,其实1的连续个数不超过a,2的连续个数不超过b. 析:dp[i][j][k] 表示前 i 个数,以 j 结尾,并且连续了k个长度,要用滚动数组,要不然MLE. 代码如下: #p ...

  5. MATLAB求解非齐次线性方程组

    例如方程组: 法1:左除法 >> A=[3 1 -1;1 2 4;-1 4 5];b=[3.6;2.1;-1.4]; >> x=A\b x = 1.4818 -0.4606 0 ...

  6. ES 6.1.2集群安装

    1.下载java,并设置环境变量 sudo tar -zxvf jdk-8u191-linux-x64.tar.gz -C /usr/local/ sudo vim /etc/profile 在最后添 ...

  7. 排序工作量之新任务(SHOI2001)

    排序工作量之新任务(SHOI2001) 给出两个整数n和t,求n的全排列中逆序对数为t的个数,和逆序对数为t的字典序最小全排列. 首先第一个问题可以用dp解决,\(f[i][j]\)表示前i个数,j个 ...

  8. Hadoop中解除 "Name node is in safe mode"的方法

    运行hadoop程序时,有时候会报以下错误,说明Hadoop的NameNode处在安全模式下. 原因分析: 在分布式文件系统启动的时候,开始的时候会有安全模式,当分布式文件系统处于安全模式的情况下,文 ...

  9. Maven中常用插件的配置

    在Maven项目的pom.xml文件中配置插件信息,使用<build></build>标签 1.配置JDK版本插件和Tomcat版本插件 <build> <! ...

  10. 误删重要文件怎么办?学会Linux 救援模式再也不担心

    背景 在运用Linux时会出现一些误操作,导致系统无法正常使用,比如删除了某个重要依赖库,或者删除了rpm等等.在这里记录下具体的操作步骤,供以后参考. 意义 学会在使用Linux系统出现误删除系统重 ...