https://codeforces.com/gym/103687
题解在cf旁边的Tutorial那里

A - JB Loves Math

本来是按照数的奇偶分类讨论,一直wa2,跑了个对拍
如果错了,可以考虑这几个样例。

由于x、y固定,所以只能考虑相差的奇偶性,而不是a、b本身的奇偶性 可以证明大转小一定能通过2步完成(+1凑奇偶 - 偶)
而小转大在相差为偶数时最少通过两步转化,关键在于凑偶数

例: 1851 6963
-> 5112 x 所以考虑拆分
-> 2556 + 2556 x
-> 2555 + 2555 + 2 x
-> 2557 + 2557 - 4 √
只能凑为 奇数 + 奇数 - 偶数(因为两个奇数必须相同)

int main() {IOS;int t;cin >> t;while(t--){int a, b;cin >> a >> b;int res = 0;if(a == b)res = 0;else if(a > b){if((a - b) % 2 == 0)res = 1;elseres = 2;}else {if((b - a) % 2)res = 1;else if((b - a) / 2 % 2)res = 2;elseres = 3;}cout << res << endl;}return 0;
}

B - JB Loves Comma

还特地判了结尾不加’,'结果wa掉,根本不用判

int main() {IOS;string s;cin >> s;if(s.find("cjb") == string::npos){cout << s;}else {while(1){int id = s.find("cjb");if(id == -1 || s.size() == 0)break;string temp = s.substr(0, id + 3);cout << temp;s = s.substr(id + 3, s.size());cout  << ',';}cout << s;}return 0;
}

C - JB Wants to Earn Big Money

水题

int main() {IOS;int n, m, k;cin >> n >> m >> k;int ans = 0;for (int i = 0; i < n; ++i){int t;cin >> t;if(t >= k)++ans;}for (int i = 0; i < m; ++i){int t;cin >> t;if(t <= k)++ans;}cout << ans;return 0;
}

G - Easy Glide

G比L好想,还是没想出来哈。想到贪心,求所有点到起点和终点的距离,然后选代价最小的,卡在了如何选择两两之间代价最小的情况,因为中间有点会断掉(超过3s)

朴素dij…

错麻了,一直wa6 -> wa34,存一下,到时候再来改
服了,这破精度

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include<climits>
#define IOS ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;const int maxx = 1e4 + 5;
const int maxn = 1e6 + 5;#define N 10000100
#define ll long long
#define endl '\n'
const ll  mod = 998244353;
#define test printf("--------------------------\n");
#define re(a) memset((a), 0, sizeof((a)))
#define remax(a) memset((a), 0x3f3f3f3f, sizeof((a)))
#define PII pair<int, int>pair<ll, ll> p[maxn];
double v1, v2;
ll n;
double t[1100][1100]; //每一个点到每一个点的用时
vector<ll> v[maxn];void dij(int j){priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;q.push({0, 0});double dist[1100];bool vis[1100];re(vis);fill(dist, dist + 1100, LLONG_MAX);dist[0] = 0;while(!q.empty()){int now = q.top().second;q.pop();if(vis[now])continue;vis[now] = true;for(auto w : v[now]){if(dist[w] > dist[now] + t[now][w]){dist[w] = dist[now] + t[now][w];q.push({dist[w], w});}}}printf("%f", dist[n + 1]);
}double timee(int i, int j){//i -> jll tem = 1ll * (p[i].first - p[j].first) * 1ll * (p[i].first - p[j].first) + 1ll * (p[i].second - p[j].second) * 1ll * (p[i].second - p[j].second);double temp = sqrt(tem);//长度double tt;if(i == 0 || i == n + 1){//没有加速功能tt = temp / v1;}else {double te = temp - 3.0 * v2;if(te > 0) {tt = 3.0 + te / v1;}elsett = temp / v2;}return tt;
}
int main() {IOS;cin >> n;for (int i = 1; i <= n; ++i){cin >> p[i].first >> p[i].second;}cin >> p[0].first >> p[0].second;cin >> p[n + 1].first >> p[n + 1].second;cin >> v1 >> v2;for (int i = 0; i <= n + 1; ++i){for (int j = 0; j <= n + 1; ++j){if (i == j)continue;t[i][j] = timee(i, j);//i -> jv[i].push_back(j);}}dij(0);return 0;
}

L - Candy Machine

犹豫了下不可能这么简单吧果然wa9
又去翻译了题,考虑过一个一个放进去,小的一定可以加在这个子集里,马上推翻

从子集里挑选比子集平均数大的数,题反复没读懂…
这题只有二分+前缀和做法

先贪选取整个集合,再更新,可以证明去掉一个最大数一定可以使整体变小,能选取的数可能会更多;找截取部分大于平均数的下标,算能选多少个

ll a[maxn];
int main() {IOS;int n;cin >> n;ll sum = 0;for (int i = 1; i <= n; ++i) {cin >> a[i];sum += a[i];}sort(a + 1, a + 1 + n);ll ans = 0, j = 0;ll avr = sum / n;ans = n - (upper_bound(a + 1, a + 1 + n, avr) - (a + 1));for (int i = n; i > 1; --i) {sum -= a[i];avr = sum / (i - 1);//cout << avr << " ";j = i - (upper_bound(a + 1, a + i, avr) - (a + 1)) - 1;//cout << j << endl;ans = max(ans, j);}cout << ans;return 0;
}

#M - BpbBppbpBB
第一判断:连通图( + 判格子形状),但存在一点问题
一看题解,啊解方程?!

I - Barbecue

觉得应该是先找回文串在哪然后减去回文长度%2判,但是,该去补马拉车了
好厉害,这题用hash处理只需要o(1)
https://www.cnblogs.com/Uninstalllingyi/p/11191045.html
O(1)字符hash板子题

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include<cmath>
#include<stack>
#include<queue>
#define IOS ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;const int maxx = 1e4 + 5;
const int maxn = 1e6 + 5;#define N 10000100
#define ll long long
#define endl '\n'
const ll  mod = 998244353;
#define test printf("--------------------------\n");
#define re(a) memset((a), 0, sizeof((a)))
#define remax(a) memset((a), 0x3f3f3f3f, sizeof((a)))
#define PII pair<int, int>
vector<int> v;#define ull unsigned long long
ull p = 13331;
ull hash_a[maxn], hash_b[maxn], power[maxn];void init(string s, int len){hash_a[0] = 0, hash_b[0] = 0, power[0] = 1;for (int i = 1; i <= len; ++i){hash_a[i] = hash_a[i - 1] * p + (s[i] - 'a');hash_b[i] = hash_b[i - 1] * p + (s[len - i + 1] - 'a');power[i] = power[i - 1] * p;}
}bool part_judge(int l, int r, int len){ull ta = hash_a[r] - hash_a[l - 1] * power[r - l + 1];ull tb = hash_b[len - l + 1] - hash_b[len - r] * power[r - l + 1];return ta == tb;
}int main() {IOS;// freopen("P1908_6.in","r",stdin);//读入数据// freopen("P1908.out","w",stdout); //输出数据int len, q;cin >> len >> q;string s;cin >> s;s = " " + s;init(s, len);for (int i = 1; i <= q; ++i){int l, r;cin >> l >> r;if(part_judge(l, r, len)){cout << "Budada" << endl;}else {if((r - l + 1) % 2){cout << "Putata" << endl;}else {cout << "Budada" << endl;}}}return 0;
}

The 19th Zhejiang Provincial Collegiate Programming Contest 2022浙江省赛 (A/B/C/G/L/I)相关推荐

  1. The 19th Zhejiang Provincial Collegiate Programming Contest

    文章目录 [A.JB Loves Math](https://codeforces.com/gym/103687/problem/A) [B.JB Loves Comma](https://codef ...

  2. The 19th Zhejiang Provincial Collegiate Programming Contest(部分题解)

    在完成三道签到之后,分别对图论.前缀&二分.大模拟上面取得突破点,但其他题集没能得到突破,仍需多加练习. A - JB热爱数学 [题意] 给定两个数 a.b.求出让a变成b的最少次数. 能修改 ...

  3. 2019 浙江省赛部分题解(The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple)

    签到题 GLucky 7 in the Pocket Time Limit: 1 Second      Memory Limit: 65536 KB BaoBao loves number 7 bu ...

  4. The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    Problem A Vertices in the Pocket 比赛地址:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?proble ...

  5. The 12th Zhejiang Provincial Collegiate Programming Contest - I Earthstone Keeper浙江省赛

    题目:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5501 思路:DFS,用了递归就溢出,所以可能得用非递归的. ...

  6. 【ZJCPC2018 第15届 浙江省赛】The 15th Zhejiang Provincial Collegiate Programming Contest(MABLJK 6题)

    补题地址:https://zoj.pintia.cn/home/news 搜索15th 本文按照通过率补的题 M. Lucky 7 题意:如果存在从给出的长为n的序列中选择一个数+b 可以被7整除,就 ...

  7. 【ZJCPC2019 第16届 浙江省赛】The 16th Zhejiang Provincial Collegiate Programming Contest(GFHIJ 5题)

    补题地址:https://zoj.pintia.cn/home/news 搜索16th 本文按照通过率补的题 G .Lucky 7 in the Pocket 题意:给出T个数,对于每个数,找出一个能 ...

  8. The 10th Zhejiang Provincial Collegiate Programming Contest 蒻菜的水题题解。

    http://acm.zju.edu.cn/onlinejudge/contestInfo.do?contestId=347 今天参加了今年的浙江省赛网络同步赛(?),被虐得很惨... 做了五道水题只 ...

  9. HZNU Training 2 for Zhejiang Provincial Collegiate Programming Contest 2019

    赛后总结: T:今天下午参加了答辩比赛,没有给予队友很大的帮助.远程做题的时候发现队友在H上遇到了挫折,然后我就和她们说我看H吧,她们就开始做了另外两道题.今天一人一道题.最后我们在研究一道dp的时候 ...

最新文章

  1. 从 Kafka 看时间轮算法设计
  2. 在线作图|小基因组——线粒体基因组圈图
  3. Ubuntu中Vim 中文乱码解决方法
  4. 设计模式--状态(State)模式
  5. Linux的内存理解
  6. Python制作AI贪吃蛇,细节、思路都写下来了!
  7. vscode 支持ansi_vscode terminal美化
  8. 无限火力挤爆服务器,LOL:无限火力出炉,众多云玩家宣布回归!服务器出现爆满情况...
  9. matleb2016A安装教程
  10. 尚硅谷谷粒商城之环境搭建
  11. Altium Designer 18生成Gerber教程
  12. PIXI 精灵表和精灵动画
  13. 产品经理如何写PRD文档[最全]
  14. 朋友圈宣传文案 朋友圈产品推广文案模板怎么写?
  15. 网络——介质访问控制
  16. CentOS 安装 kafka 扩展
  17. matlab运行提示未找到文件解决方法
  18. Linux top命令参数及使用方法详解
  19. Python爬虫新手入门教学(十七):爬取yy全站小视频
  20. R12.2.0 post install checks error : RW-50016: Error: - {0} was not created - 1

热门文章

  1. iOS开发笔记之二十四——Xcode下类中供外部调用的方法添加注释说明技巧
  2. 前端面试常见面试题及答案
  3. Java 实现调度算法 包括 FCFS(FIFO)、优先权排队、循环排队、加权公平排队(WFQ)
  4. 编程实现根据公式π/4=1-(1/3)+(1/5)-(1/7)...计算π的值
  5. 汽车驱动力及发动机转矩曲线在python中拟合
  6. Squeeze-and-Attention Networks for Semantic Segmentation解读
  7. 再说for in循环
  8. 错误:类 xxx 是公共的, 应在名为 xxx.java 的文件中声明
  9. 第2课:5G标准小知识
  10. 软文营销拒绝一成不变用故事建立情感依恋