比赛链接:https://codingcompetitions.withgoogle.com/kickstart/round/0000000000436140

K-Goodness String (5pts, 7pts)

判断字符不同值,计算得分至K的差值

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int T;
cin >> T;
for (int i = 1; i <= T; ++i) {
int n, k, cnt = 0;
cin >> n >> k;
string s;
cin >> s;
for (int i = 0; i < n / 2; ++i)
if (s[i] != s[n - i - 1]) cnt++;
// cout << cnt << "\n";
if (cnt == k) cnt = 0;
else
cnt = abs(k - cnt);
cout << "Case #" << i << ": " << cnt << "\n";
}
return 0;
}

L Shaped Plots (8pts, 12pts)

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N, M, a[1005][1005], l[1005][1005], r[1005][1005], u[1005][1005],
d[1005][1005]; int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int T;
cin >> T;
for (int ca = 1; ca <= T; ca++) {
cin >> N >> M;
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j) cin >> a[i][j]; memset(l, 0, sizeof(l)), memset(r, 0, sizeof(r));
memset(u, 0, sizeof(u)), memset(d, 0, sizeof(d));
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++) {
if (a[i][j])
l[i][j] = l[i][j - 1] + 1, u[i][j] = u[i - 1][j] + 1;
} int ret = 0;
for (int i = N; i > 0; i--)
for (int j = M; j > 0; j--)
if (a[i][j]) {
r[i][j] = r[i][j + 1] + 1, d[i][j] = d[i + 1][j] + 1;
// lu
ret += max(0, min(l[i][j], u[i][j] / 2) - 1);
ret += max(0, min(l[i][j], d[i][j] / 2) - 1);
ret += max(0, min(r[i][j], u[i][j] / 2) - 1);
ret += max(0, min(r[i][j], d[i][j] / 2) - 1);
ret += max(0, min(u[i][j], l[i][j] / 2) - 1);
ret += max(0, min(u[i][j], r[i][j] / 2) - 1);
ret += max(0, min(d[i][j], l[i][j] / 2) - 1);
ret += max(0, min(d[i][j], r[i][j] / 2) - 1);
}
cout << "Case #" << ca << ": " << ret << "\n";
}
return 0;
}

Rabbit House (9pts, 15pts)

BFS 搜索

// RioTian 21/03/22
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;
int dx[] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int n, m, a[400][400], b[400][400];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int T;
cin >> T;
for (int i = 1; i <= T; ++i) {
cin >> n >> m;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j) cin >> a[i][j]; memset(b, -1, sizeof(b));
priority_queue<pair<int, pair<int, int>>> h;
ll cnt = 0;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
h.push(make_pair(a[i][j], make_pair(i, j))); while (h.size()) {
auto t = h.top();
h.pop(); int x = t.second.first, y = t.second.second;
if (b[x][y] < 0) {
b[x][y] = t.first;
cnt += t.first - a[x][y];
for (int k = 0; k < 4; ++k) {
int nx = x + dx[k], ny = y + dy[k];
if (nx > 0 && nx <= n && ny > 0 && ny <= m &&
a[nx][ny] + 1 < b[x][y])
h.push(make_pair(t.first - 1, make_pair(nx, ny)));
}
}
}
cout << "Case #" << i << ": " << cnt << "\n";
}
return 0;
}

Checksum (10pts, 17pts, 17pts)

这道题没做出来。先记录一下dalao的解法

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue> using namespace std; const int MAXN = 100005, dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int N, M, a[505][505], b[505][505], ur[505], uc[505], fa[1005];
pair<int, int> c[505 * 505]; void init() {
scanf("%d", &N);
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++) scanf("%d", &a[i][j]);
M = 0;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++) {
scanf("%d", &b[i][j]);
if (b[i][j] > 0) {
c[++M] = make_pair(-b[i][j], (i - 1) * N + (j - 1));
}
}
for (int i = 1; i <= N; i++) scanf("%d", &ur[i]);
for (int i = 1; i <= N; i++) scanf("%d", &uc[i]);
} int findSet(int x) {
if (!fa[x]) return x;
fa[x] = findSet(fa[x]);
return fa[x];
} void work() {
memset(fa, 0, sizeof(fa));
sort(c + 1, c + M + 1);
int ret = 0;
for (int i = 1; i <= M; i++) {
int x = c[i].second / N + 1, y = c[i].second % N + 1 + N;
int bx = findSet(x), by = findSet(y);
if (bx != by) {
if (rand() % 2) fa[bx] = by;
else
fa[by] = bx;
} else
ret -= c[i].first;
}
printf("%d\n", ret);
} int main() {
// freopen("d.in", "r", stdin), freopen("d.out", "w", stdout);
int T;
cin >> T;
for (int ca = 1; ca <= T; ca++) {
printf("Case #%d: ", ca);
init();
work();
}
return 0;
}

Round A 2021 - Kick Start 2021的更多相关文章

  1. [Kick Start] 2021 Round B

    题目:Kick Start 2021 Round-B . Increasing Substring 输出字符串中每个字符的最长 Increasing Substring 的长度,非常简单的动态规划问题 ...

  2. [Kick Start] 2021 Round A

    题目:2021 Round-A . K-Goodness String 签到题,计算当前字符串的 K-Goodness Score ,然后与给出的 K 做差即可. #include <iostr ...

  3. 郑政 | 2021软件代码开发技术作业四 | 需求改进&系统设计

    需求改进&系统设计 -------------------------------------------------------------------------------------- ...

  4. GitHub Universe 2021|MS Reactor 邀你共聚年度盛会

    GitHub Universe 2021 将于2021年10月27-28日(PDT)在线直播,MS Reactor 将与 CSDN 合作进行转播,与你一同观看这场全球开发者盛会. 关于 GitHub ...

  5. 2021 CSP-J复赛 我的备战与游记

    目录 备战 2021.10.18 2021.10.19 2021.10.20 2021.10.21 2021.10.22 比赛当日 早上 线下见面 正文 比赛后 赛后总结与讲解 简单总结 Candy ...

  6. 议题征集令 | Apache DolphinScheduler Meetup 2021 来啦,议题征集正式开启!

    点击上方 蓝字关注我们 社区的小伙伴们,经过精心筹备,我们很高兴地宣布,Apache DolphinScheduler Meetup 2021 将于 2021 年 11 月 27 日到来! 在 Mee ...

  7. Codeforces Round #697 (Div. 3)

    A.Odd Divisor 题意:问一个数是不是含有奇数因子 思路:就直接给这个数循环除以2,看看最后剩下的数是不是0,如果不是就有奇数因子,如果是就没有 想不到:1)当时想着用log2来解决问题,后 ...

  8. (转)TCP注册端口号大全

    分类: 网络与安全 cisco-sccp 2000/tcp Cisco SCCPcisco-sccp 2000/udp Cisco SCCp# Dan Wing <dwing&cisco ...

  9. unix &amp; linux oralce用户 内存使用情况分析

    Linux*********************************************************************************************** ...

  10. 网络-05-端口号-F5-负载均衡设-linux端口详解大全--TCP注册端口号大全备

    [root@test1:Standby] config # [root@test1:Standby] config # [root@test1:Standby] config # [root@test ...

随机推荐

  1. [FJOI2017]矩阵填数 (容斥原理)

    题目传送门 现在看来熊猫杯的J题原来是个容斥套路题,按照值域排序后根据值域划分方块数,枚举子集容斥计算即可. #include<cstdio> #include<algorithm& ...

  2. [CF1748F] Circular Xor Reversal

    题目描述 You have an array $ a_0, a_1, \ldots, a_{n-1} $ of length $ n $ . Initially, $ a_i = 2^i $ for ...

  3. C++学习笔记九:值,常量,常表达式和常初始化

    1. 值: Literal: Data that is directly represented in code without going through some other variable s ...

  4. LLM面面观之LLM复读机问题及解决方案

    1. 背景 关于LLM复读机问题,本qiang~在网上搜刮了好几天,结果是大多数客观整理的都有些支离破碎,不够系统. 因此,本qiang~打算做一个相对系统的整理,包括LLM复读机产生的原因以及对应的 ...

  5. Transformer在量化投资的应用

    导语 RNN.LSTM和GRU网络已在序列模型.语言模型.机器翻译等应用中取得不错的效果.循环结构(recurrent)的语言模型和编码器-解码器体系结构取得了不错的进展. 但是,RNN固有的顺序属性 ...

  6. Rabbit加密算法

    一.引言 随着信息技术的快速发展,数据安全已成为越来越受到重视的领域.加密算法作为保障数据安全的重要技术手段,在通信.存储等领域得到了广泛应用.Rabbit加密算法作为一种新型的加密算法,凭借其简单易 ...

  7. Python笔记一之excel的读取

    本文首发于公众号:Hunter后端 原文链接:Python笔记一之excel的读取 这里我常用的 python 对于 excel 的读取库有两个,一个是 xlsxwriter 用于操作 excel 的 ...

  8. 学一点关于JVM类加载的知识

    要研究类加载过程,我们先要知道关于 Java 处理代码的流程是怎么样的. 第一步:编写源代码 这一步是我们最熟悉的,就是我们在 idea 上写的业务代码,生成 Example.java 文件. pub ...

  9. Python——第五章:time模块、datetime模块

    time模块 在平常的代码中,我们常常需要与时间打交道.在Python中,与时间处理有关的模块就包括:time,datetime,calendar(很少用,不讲),下面分别来介绍. 我们写程序时对时间 ...

  10. OfficeWeb365任意文件读取

    OfficeWeb365任意文件读取 OfficeWeb365 /Pic/Indexs接口处存在任意文件读取漏洞,攻击者可通过独特的加密方式对payload进行加密,读取任意文件,获取服务器敏感信息, ...