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

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

  2. Educational Codeforces Round 94 题解

    我竟然比到了全场的 rk 14,incredible! A 大水题,直接输出 \(n\) 遍 \(s_n\) 即可. B 分类讨论题,放在 B 题可能难度有点大了. 直接暴力枚举你拿了多少个宝剑,然后 ...

  3. Educational Codeforces Round 37-F.SUM and REPLACE题解

    一.题目 二.题目链接 http://codeforces.com/contest/920/problem/F 三.题意 给定$N$个范围在$[1, 1e6)$的数字和$M$个操作.操作有两种类型: ...

  4. Educational Codeforces Round 94 (Rated for Div. 2)【ABCD】

    比赛链接:https://codeforces.com/contest/1400 A. String Similarity 题意 给出一个长 $2n-1$ 的二进制串 $s$,构造一个长 $n$ 的字 ...

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

  6. Educational Codeforces Round 94 (Rated for Div. 2) B. RPG Protagonist (数学)

    题意:你和你的随从去偷剑和战斧,你可以最多可以拿\(p\)重的东西,随从可以拿\(f\)重的东西,总共有\(cnt_{s}\)把剑,\(cnt_{w}\)把战斧,每把剑重\(s\),战斧重\(w\), ...

  7. Educational Codeforces Round 37-G.List Of Integers题解

    一.题目 二.题目链接 http://codeforces.com/contest/920/problem/G 三.题意 给定一个$t$,表示有t次查询.每次查询给定一个$x$, $p$, $k$,需 ...

  8. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  9. Educational Codeforces Round 12 B C题、

    B. Shopping 题意:n个顾客,每个顾客要买m个物品,商场总共有k个物品,看hint就只知道pos(x)怎么算了,对于每一个Aij在k个物品中找到Aij的位置.然后加上这个位置对于的数值,然后 ...

  10. Educational Codeforces Round 10 A B题、

    A. Gabriel and Caterpillar 题意: 就是说  一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方.毛毛虫从10点爬到22点.每小时爬的距离是a, 晚上22点到第二天早上10点 ...

随机推荐

  1. mongodb c driver bson的嵌套访问与层次结构

    使用c访问mongodb,需要用到mongodb c driver.c++的driver也是基于c driver封装的. 在使用c driver访问mongodb时,需要与bson打交道,不过c dr ...

  2. [AI]探寻高等生命的多面驱动

    引子 意识从来是一个前沿课题,充满了学术大神,也充满了神棍.对于意识的讨论和研究需要保持开放的思想,也要遵守理性的严格的方法.我们不是着急去推翻什么或者声称发现了什么,我们大部分要做的事情是把实验多重 ...

  3. 2019牛客国庆集训派对day3 G排列(状压dp)

    题目传送门 一道很好的状压DP,状态是当前的占位情况,排序操作和第21次CSP认证的第四题作用类似. #include<cstdio> #include<vector> #in ...

  4. 光学测量 PPG

    参考来源:ADI官网技术文章.知乎(hxl695822705.KingPo-张超.深圳加1健康科技 ) 现状 PPG测量心率.血氧的技术距今发展快100年,影响心率.血氧测量准确度的因素主要有心率传感 ...

  5. C# 获取系统DPI缩放比例以及分辨率大小

    一般方法 System.Windows.Forms.Screen类 // 获取当前主屏幕分辨率 int screenWidth = Screen.PrimaryScreen.Bounds.Width; ...

  6. 【YOLOv5】实现扑克牌的点数识别

    前言 其实年初的时候,我也跟着别人的源码,用 Tensoflow 实现过扑克牌的目标检测.虽然也通过博文的方式记录了,但是那个项目使用的 TF 版本比较旧,自身对 TF 并不熟.后期如果说要升级或修改 ...

  7. Java核心知识体系8:Java如何保证线程安全性

    Java核心知识体系1:泛型机制详解 Java核心知识体系2:注解机制详解 Java核心知识体系3:异常机制详解 Java核心知识体系4:AOP原理和切面应用 Java核心知识体系5:反射机制详解 J ...

  8. MongoDB中的分布式集群架构

    MongoDB 中的分布式集群架构 前言 Replica Set 副本集模式 副本集写和读的特性 Sharding 分片模式 分片的优势 MongoDB 分片的组件 分片键 chunk 是什么 分片的 ...

  9. Spring Boot内置的一些工具类

    1.断言Assert工具类 // 要求参数 object 必须为非空(Not Null),否则抛出异常,不予放行 // 参数 message 参数用于定制异常信息. void notNull(Obje ...

  10. 【scikit-learn基础】--『预处理』之 离散化

    数据的预处理是数据分析,或者机器学习训练前的重要步骤.通过数据预处理,可以 提高数据质量,处理数据的缺失值.异常值和重复值等问题,增加数据的准确性和可靠性 整合不同数据,数据的来源和结构可能多种多样, ...