Educational Codeforces Round 94 (A - D题题解)
https://codeforces.com/contest/1400/problem/A

Example
input
4
1
1
3
00000
4
1110000
2
101
output
1
000
1010
00
思路:先贴下代码,有事要去医院,等会补上思路。
AC代码:
#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
void solve() {
int n; string s;
cin >> n >> s;
for (int i = 0; i < n; ++i)
cout << s[n - 1];
cout << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)solve();
}
https://codeforces.com/contest/1400/problem/B

Example
input
3
33 27
6 10
5 6
100 200
10 10
5 5
1 19
1 3
19 5
output
11
20
3
思路:
AC代码:
#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
const int N = 1e5 + 100;
typedef long long ll;
ll n, m, a[N];
void solve() {
int p, f;
cin >> p >> f;
int cnts, cntw, s, w;
cin >> cnts >> cntw >> s >> w;
if (s > w) {
swap(s, w);
swap(cnts, cntw);
}
int maxi = 0;
for (int i = 0; i <= min(cnts, p / s); i++) {
int a = min(cntw, (p - i * s) / w);
int b = min(cnts - i, f / s);
int c = min(cntw - a, (f - b * s) / w);
maxi = max(maxi, a + b + c + i);
}
cout << maxi << '\n';
}
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)solve();
}
https://codeforces.com/contest/1400/problem/C

Example
input
3
101110
2
01
1
110
1
output
111011
10
-1
思路:
AC代码:
#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
const int N = 1e5 + 100;
typedef long long ll;
ll n, m, a[N];
void solve() {
ll x; string s, ss = "";
cin >> s >> x;
int n = s.size();
for (int i = 0; i < n; ++i) ss += '1';
for (int i = 0; i < n; ++i) {
if (s[i] == '0' && i + x < n)ss[i + x] = '0';
if (s[i] == '0' && i - x >= 0)ss[i - x] = '0';
}
bool flag = true;
for (int i = 0; i < n; ++i) {
if (s[i] == '1') {
bool ok = false;
if (i + x < n && ss[i + x] == '1') ok = true;
if (i - x >= 0 && ss[i - x] == '1') ok = true;
if (!ok) flag = false;
}
}
if (!flag)cout << -1 << endl;
else cout << ss << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)solve();
}
https://codeforces.com/contest/1400/problem/D

Example
input
2
5
2 2 2 2 2
6
1 3 3 1 2 3
output
5
2
思路:
AC代码: 使用map,900+ms
#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
const int N = 1e5 + 100;
typedef long long ll;
ll a[N];
map<int, int>m1, m2;
void solve() {
m1.clear();
int n; cin >> n;
for (int i = 0; i < n; ++i)cin >> a[i];
ll ans = 0;
for (int i = 0; i < n; ++i) {
m2.clear();
for (int j = n - 1; j > i; --j)
ans += m1[a[j]] * m2[a[i]], ++m2[a[j]];
++m1[a[i]];
}
cout << ans << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)solve();
}
Educational Codeforces Round 94 (A - D题题解)的更多相关文章
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- Educational Codeforces Round 94 题解
我竟然比到了全场的 rk 14,incredible! A 大水题,直接输出 \(n\) 遍 \(s_n\) 即可. B 分类讨论题,放在 B 题可能难度有点大了. 直接暴力枚举你拿了多少个宝剑,然后 ...
- Educational Codeforces Round 37-F.SUM and REPLACE题解
一.题目 二.题目链接 http://codeforces.com/contest/920/problem/F 三.题意 给定$N$个范围在$[1, 1e6)$的数字和$M$个操作.操作有两种类型: ...
- Educational Codeforces Round 94 (Rated for Div. 2)【ABCD】
比赛链接:https://codeforces.com/contest/1400 A. String Similarity 题意 给出一个长 $2n-1$ 的二进制串 $s$,构造一个长 $n$ 的字 ...
- Educational Codeforces Round 94 (Rated for Div. 2) D. Zigzags (枚举,前缀和)
题意:有一长度为\(n(4\le n\le 3000)\)的数组,选择四个位置\((i,j,k,l)\ (1\le i<j<k\le n)\),使得\(a_i=a_k\)并且\(a_j=a ...
- Educational Codeforces Round 94 (Rated for Div. 2) B. RPG Protagonist (数学)
题意:你和你的随从去偷剑和战斧,你可以最多可以拿\(p\)重的东西,随从可以拿\(f\)重的东西,总共有\(cnt_{s}\)把剑,\(cnt_{w}\)把战斧,每把剑重\(s\),战斧重\(w\), ...
- Educational Codeforces Round 37-G.List Of Integers题解
一.题目 二.题目链接 http://codeforces.com/contest/920/problem/G 三.题意 给定一个$t$,表示有t次查询.每次查询给定一个$x$, $p$, $k$,需 ...
- Educational Codeforces Round 23 A-F 补题
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...
- Educational Codeforces Round 12 B C题、
B. Shopping 题意:n个顾客,每个顾客要买m个物品,商场总共有k个物品,看hint就只知道pos(x)怎么算了,对于每一个Aij在k个物品中找到Aij的位置.然后加上这个位置对于的数值,然后 ...
- Educational Codeforces Round 10 A B题、
A. Gabriel and Caterpillar 题意: 就是说 一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方.毛毛虫从10点爬到22点.每小时爬的距离是a, 晚上22点到第二天早上10点 ...
随机推荐
- HTTP 和 HTTPS 之间除了安全性区别外,还有哪些区别
HTTP 和 HTTPS 是两种常见的网络协议,它们都是用于在浏览器和服务器之间传输数据的.但是,它们之间也有一些重要的区别,这些区别涉及到数据的安全性.传输性能.使用成本和搜索排名等方面.本文将从以 ...
- python函数定义、调用、参数、返回
python函数定义语法: 定义: Def foo(): print('bar') print('bar2') 如果函数内容特别少,可以一行定义 : Def foo(): print('bar') ...
- PanguHA,一款Windows双机热备工具
1.简介 PanguHA是Windows平台的双机热备集群系统,是提供系统高可用性的解决方案,一般由两个节点构成,分为活动节点及备用节点(两者之间可以相互切换),软件界面如下 PanguHA下载地址 ...
- 5分钟攻略Spring-Retry框架实现经典重试场景
前言 今天分享干货,控制了篇幅,5分钟内就能看完学会. 主题是Spring-Retry框架的应用,做了一个很清晰的案例,代码可下载自测. 框架介绍 Spring-Retry框架是Spring自带的功能 ...
- 若依vue启动报Error: error:0308010C:digital envelope routines::unsupported
解决:若依vue启动报Error: error:0308010C:digital envelope routines::unsupported 1.描述: 问题产生原因是因为 node.js V17版 ...
- vscode快速配置汇编环境
微机原理的课程需要,简单快速记录环境的搭建 找到并安装插件masm. MASM/TASM的汇编工具默认是tasm这样就无法在vscode终端进行debug,打开插件设置如下修改: 测试代码实现小写字母 ...
- 8种超简单的Golang生成随机字符串方式
本文分享自华为云社区<Golang生成随机字符串的八种方式与性能测试>,作者: 张俭. 前言 这是**icza**在StackOverflow上的一篇高赞回答,质量很高,翻译一下,大家一起 ...
- libGDX游戏开发之按轨迹移动(十一)
libGDX游戏开发之运动轨迹绘制(十一) libGDX系列,游戏开发有unity3D巴拉巴拉的,为啥还用java开发?因为我是Java程序员emm-国内用libgdx比较少,多数情况需要去官网和go ...
- 开源云原生网关Linux Traefik本地部署结合内网穿透远程访问
开源云原生网关Linux Traefik本地部署结合内网穿透远程访问 前言 Træfɪk 是一个云原生的新型的 HTTP 反向代理.负载均衡软件,能轻易的部署微服务.它支持多种后端 (Docker ...
- GeminiDB Cassandra接口新特性PITR发布:支持任意时间点恢复
本文分享自华为云社区<GeminiDB Cassandra接口新特性PITR发布:支持任意时间点恢复>,作者: GaussDB 数据库. 技术背景 当业务发生数据损毁.数据丢失.数据误删除 ...