做了四个题。。

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. 【mongodb】json与bson区别

    bson是由10gen开发的一个数据格式,目前主要用于mongoDB中,是mongoDB的数据存储格式.bson基于json格式,选择json进行改造的原因主要是json的通用性及json的schem ...

  2. 教育网bt站点

    北京交通大学 晨光BT (http://cgbt.cn)清华晨光BT(http://thubt.cn)北京科技大学 iBeiKeBT(http://bt.ibeike.com)上海大学 乐乎BT (h ...

  3. ArrayList反转

    Collections.reverse(arrayList); 下面看例子: import java.util.ArrayList;import java.util.Collections; publ ...

  4. 使用Paramiko的问题

    在使用Paramiko远程登录的时候,会报sudo: sorry, you must have a tty to run sudo 切换到root用户,使用visudo命令,然后就会打开一个文本,在文 ...

  5. 3. Shodan新手入坑指南

    什么是 Shodan? 首先,Shodan 是一个搜索引擎,但它与 Google 这种搜索网址的搜索引擎不同,Shodan 是用来搜索网络空间中在线设备的,你可以通过 Shodan 搜索指定的设备,或 ...

  6. myeclipse 不能重新编译 web .classpath文件修改

    这个问题困扰我好久了,就是当你从另一个workspace中拷到另一个workspace中,然后在import进myeclipse中就会出现无论你怎么改代码,编译完成后webroot目录下的classe ...

  7. struts2知识点汇总

    标签遍历Map<key,List<Object>> listMap=new HashMap<String,List<Student>>(); List& ...

  8. C++基础之数据类型和表达式

    面向对象特征1)封装 (类)2)继承(基类和派生类)3)多态(通过定义虚函数支持动态联编) 面向对象三要素(类-创建对象的样板,对象,继承) C++基本数据类型整型 int  (32位机,字宽4字节, ...

  9. validate验证注册表单

    点击预览; <%@ page language="java" contentType="text/html; charset=UTF-8" pageEnc ...

  10. [Xcode 实际操作]四、常用控件-(8)UITextField控件的使用

    目录:[Swift]Xcode实际操作 本文将演示文本输入框控件的基本用法. 文本输入框主要用来接收和显示用户输入的内容. 在项目导航区,打开视图控制器的代码文件[ViewController.swi ...