2021 CCPC女生赛
newbie,A了五题铜牌收工
比赛时和队友悠哉游哉做题,想着干饭,最后幸好没滚出铜尾。
贴一下比赛过的代码
A题 签到
队友A的,判断正反方向序列是否符合要求
/***
* @Author: _Krill
* @Date: 2021-10-31 09:00:34
* @LastEditTime: 2021-10-31 09:54:36
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int station[10];
int bussta[10];
int n,x,y,m;
int func(){
bool flag1=true;
bool flag2=true;
for(int i=x+1,j=1;i<=x+m;i++,j++){
if(bussta[j]!=station[i]){
flag1=false;
break;
}
}
for(int i=x-1,j=1;i>=x-m;i--,j++){
if(bussta[j]!=station[i]){
flag2=false;
break;
}
}
if(flag1&&flag2){
return 0;
}
else if(flag1&&!flag2)
return 1;
else
return -1;
}
int main()
{
// IO_fast
cin>>n>>x>>y;
for(int i=1;i<=n;i++){
cin>>station[i];
}
cin>>m;
if(m>abs(x-y)){
cout<<"Wrong"<<endl;
return 0;
}
for (int i = 1; i <= m; i++)
{
cin>>bussta[i];
}
int fu=func();
if(fu==0)
cout<<"Unsure"<<endl;
else if(fu==1){
if(x>y)
cout<<"Wrong"<<endl;
else
cout<<"Right"<<endl;
}
else{
if(x>y)
cout<<"Right"<<endl;
else{
cout<<"Wrong"<<endl;
}
}
return 0;
}
D题
刚看以为是最小生成树,实际上毫无关系。
把所有村庄按费用从大到小排序,依次检查是不是边界,是边界就加两次,否则加一次。
/***
* @Author: _Krill
* @Date: 2021-10-31 09:13:24
* @LastEditTime: 2021-10-31 09:54:45
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
struct node {
int num, e;
};
node arr[200005];
bool cmp(const node& a, const node& b) {
return a.num > b.num;
}
int vis[200005];
int main()
{
IO_fast
int n;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> arr[i].num;
arr[i].e = i + 1;
}
ll sum = 0;
int cnt = 0;
sort(arr, arr + n, cmp);
for(int i = 0; i < n && cnt < n; i++ ) {
vis[arr[i].e] = 1;
if(arr[i].e - 1 >= 1) {
if(!vis[arr[i].e - 1]) {
sum += arr[i].num;
cnt++;
}
}
if(arr[i].e + 1 <= n) {
if(!vis[arr[i].e + 1]) {
sum += arr[i].num;
cnt++;
}
}
}
cout << sum << '\n';
return 0;
}
G题 签到
队友A的,求 1 / n
/***
* @Author: _Krill
* @Date: 2021-10-31 10:08:07
* @LastEditTime: 2021-10-31 10:17:15
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int x,y;
cin>>x>>y;
}
double ans;
ans=1.0/n;
printf("%16f",ans)
}
I题 模拟题
debug了好久,恰好饭点,也就饭后甜点解决了~
开始队友提供思路左转右转45度就是三角函数的变化,but脑子短路,也没写对。
最后是用dx,dy方向数组,+1表示右转,-1表示左转,开始是向前的,状态为 (-1, 0)。
/***
* @Author: _Krill
* @Date: 2021-10-31 10:05:05
* @LastEditTime: 2021-10-31 12:48:36
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef pair<int, int> pp;
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int n, m;
char arr[55][55];
int curV = 0;
int dire = 0;
bool judge(int xx, int yy) {
if(dx[dire] != 0 && dy[dire] != 0) {
int t1 = (dire - 1 + 8) % 8, t2 = (dire + 1) % 8;
if(arr[xx + dx[t1]][yy + dy[t1]] == '#' && arr[xx + dx[t2]][yy + dy[t2]] == '#') return false;
}
return true;
}
pp move(pp st) {
int xx = st.first, yy = st.second;
for(int i = 0; i < curV; i++) {
xx += dx[dire], yy += dy[dire];
if(xx <= 0 || xx > n || yy <= 0 || yy > m || arr[xx][yy] == '#' || !judge(st.first, st.second)) {
cout << "Crash! ";
curV = 0;
return st;
}
st = pp(xx, yy);
}
return st;
}
int main()
{
int q;
pp st;
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> arr[i][j];
if(arr[i][j] == '*') {
st = pp(i, j);
arr[i][j] = '.';
}
}
}
string op;
cin >> q >> op;
for(int i = 0; i < q; i++) {
if(op[i] == 'L') {
dire = (dire - 1 + 8) % 8;
}
else if(op[i] == 'R') {
dire = (dire + 1) % 8;
}
else if(op[i] == 'U') {
curV += 1;
}
else {
curV = max(curV - 1, 0);
}
st = move(st);
cout << st.first << ' ' << st.second << '\n';
}
return 0;
}
K题 统计 '-' 的个数,签到。
/***
* @Author: _Krill
* @Date: 2021-10-31 09:02:15
* @LastEditTime: 2021-10-31 18:06:19
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int main()
{
IO_fast
int n;
cin >> n;
int cnt = 0;
char ch;
while(cin >> ch) {
if(ch == '-') cnt++;
}
cout << cnt << '\n';
return 0;
}
之后还开了 B 题和 C 题,B 题题目意思真难懂,猜了一下没通过样例,时间还剩半个小时,队友建议转向 C 题。C 题数据范围很小,想了下用 DFS 回溯,刚写的时候毒奶自己每次写回溯都会有 bug,果不其然,到最后两分钟,样例还是没过,随终。
队里都没时间准备,所以拿到铜还是挺满意的,如果做题时没那么悠哉闲聊,感觉还是可以把 C 调出来
补题了
2021 CCPC女生赛的更多相关文章
- 2019.ccpc女生赛-wfinal总结
2019ccpc女生赛离它结束有四天了,在这个期间我想了很多,想了想还是决定写这个总结.作为这个队伍唯一的一名大一队员,我很庆幸,能跟着两个学姐一起打比赛,计爱玲师姐,即将工作,张莹俐学姐.这估计都是 ...
- 2018 CCPC 女生赛 hdoj6287 口算训练
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6287 Summarize: 1.分解质因数: 2.二分查找函数lower_bound与upper_bo ...
- 2018 CCPC 女生赛 hdoj6288 缺失的数据范围
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6288 Summarize:1.二分查找答案: 2.自带log函数精度不够,需自己写: 3.注意二分递归 ...
- 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree
// 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...
- (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...
- 2018 CCPC网络赛
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...
- ccpc 网络赛 hdu 6155
# ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...
- # 江西ccpc省赛-waves-(DP做法)
江西ccpc省赛-waves-(DP做法) 题链:http://acm.hdu.edu.cn/showproblem.php?pid=6570 题意:给你长度为N,1≤N≤100000的一个数组,其中 ...
- # 江西CCPC省赛-Rng(概率+逆元)
江西CCPC省赛-Rng(概率+逆元) 题意: 给出一个n,在[1,n]之间选一个R1,在[1,R1]之间选一个L1,得到区间[L1,R1],同理获取区间[L2,R2],问两个区间相交的概率对1e9+ ...
随机推荐
- prometheus从零开始
本次的想法是做服务监控 并告警 主要线路如下图所示 1.运行prometheus docker方式 docker run -itd \ -p 9090:9090 \ -v /opt/prometh ...
- 通过Wireshark抓包分析谈谈DNS域名解析的那些事儿
文/朱季谦 本文主要想通过动手实际分析一下是如何通过DNS服务器来解析域名获取对应IP地址的,毕竟,纸上得来终觉浅,绝知此事要躬行. 域名与IP地址 当在浏览器上敲下"www.baidu.c ...
- hadoop集群搭建详细教程
本文针对hadoop集群的搭建过程给予一个详细的介绍. 参考视频教程:https://www.bilibili.com/video/BV1tz4y127hX?p=1&share_medium= ...
- C++快速读入
使用C++的标准cin进行读入速度比较慢,尤其是在大数据的情况下,所以我们需要使用一种方法,按照字符读入,最后再"组装"成整数.由于字符读入比数字要快,所以这样做可以提高读入速度. ...
- 解决sofaboot项目右键入口方法没有run sofa application
选中入口方法名,右键出现run sofa application
- 简单学习PHP中的层次性能分析器
在 PHP 中,我们需要进行调试的时候,一般都会使用 memory_get_usage() 看下内存的使用情况.但如果想看当前的脚本 CPU 的占用情况就没有什么现成的函数了.不过,PHP 也为我们提 ...
- symfony2中mysql和mongodb的增删改查总结
https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manip ...
- C# lambda 实现 Ascii 排序
var dir = new Dictionary<string, string>(); dir.Add("channelId", "1& ...
- js 模板方法模式
* 分离出共同点 function Beverage() {} Beverage.prototype.boilWater = function() { console.log("把水煮沸&q ...
- hibernate 初学
1. hibernate的基本操作 执行流程: 执行流程细节:基本的配置文件 可以与mybatis进行对比着记 hibernate 的主键生成策略 ...