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点 ...
随机推荐
- Java 21 官方速览:全面拥抱虚拟线程
前言 首先,感谢一下不少xdm私信关心我的身体状况,我也不是什么厉害的大佬,点开通知看到一堆私信还是蛮感动的. 近来有意大幅缩短了更新频率,增加了日常调养身体的时间,淋巴结确实变小了,睡眠也逐渐正常, ...
- springCore完整学习教程2,入门级别
上集说到:2. 3,咱们从2.3集开始 2. Externalized Configuration 2.3. External Application Properties Spring Boot会自 ...
- ubuntu20.04安装goaccess实时对nginx日志进行分析
ubuntu20.04安装goaccess实时对nginx日志进行分析 goaccess可以对nginx日志进行分析,生成实时动态页面,同时通过nginx反向代理来解决WebSocket数据传输问题. ...
- Tensorflow2.0实战之GAN
本文主要带领读者了解生成对抗神经网络(GAN),并使用提供的face数据集训练网络 GAN 入门 自 2014 年 Ian Goodfellow 的<生成对抗网络(Generative Adve ...
- 欧奈尔的RPS指标如何使用到股票预测
前言 1988年,欧奈尔将他的投资理念写成了<笑傲股市How to Make Money in Stocks>.书中总结了选股模式CANSLIM模型,每一个字母都代表一种尚未发动大涨势的潜 ...
- Scrapy在pipeline中集成mongodb
settings.py中设置配置项 MONGODB_HOST = "127.0.0.1" MONGODB_PORT = 27017 MONGODB_DB_NAME = " ...
- Scrapy-CrawlSpider爬虫类使用案例
CrawlSpider类型的爬虫会根据指定的rules规则自动找到url比自动爬取. 优点:适合整站爬取,自动翻页爬取 缺点:比较难以通过meta传参,只适合一个页面就能拿完数据的. import s ...
- [转]NLog学习笔记
配置文件 NLog所有的配置信息都可以写到一个单独的xml文件中,也可以在程序代码中进行配置. 配置文件位置 启动的时候,NLog会试图查找配置文件完成自动配置,查找的文件依次如下(找到配置信息则结束 ...
- Python趣味入门12:初遇类与实例
小牛叔用轻松有趣的故事,带你进入Python的编程世界. 1.类 一提到类大神们就经常说封装.说白了,封装即把围绕同一个对象相同的代码.数据整合在一起.比如在某段游戏代码中(比如熊猫厨房),有一个&q ...
- CTFHub XSS DOM跳转 WriteUp
前文:DOM反射XSS 进入网站,直接查看源代码,下面是关键代码,这里有xss漏洞: <script> var target = location.search.split("= ...