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女生赛的更多相关文章

  1. 2019.ccpc女生赛-wfinal总结

    2019ccpc女生赛离它结束有四天了,在这个期间我想了很多,想了想还是决定写这个总结.作为这个队伍唯一的一名大一队员,我很庆幸,能跟着两个学姐一起打比赛,计爱玲师姐,即将工作,张莹俐学姐.这估计都是 ...

  2. 2018 CCPC 女生赛 hdoj6287 口算训练

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6287 Summarize: 1.分解质因数: 2.二分查找函数lower_bound与upper_bo ...

  3. 2018 CCPC 女生赛 hdoj6288 缺失的数据范围

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6288 Summarize:1.二分查找答案: 2.自带log函数精度不够,需自己写: 3.注意二分递归 ...

  4. 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

    // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...

  5. (四面体)CCPC网络赛 HDU5839 Special Tetrahedron

    CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...

  6. 2018 CCPC网络赛

    2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...

  7. ccpc 网络赛 hdu 6155

    # ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...

  8. # 江西ccpc省赛-waves-(DP做法)

    江西ccpc省赛-waves-(DP做法) 题链:http://acm.hdu.edu.cn/showproblem.php?pid=6570 题意:给你长度为N,1≤N≤100000的一个数组,其中 ...

  9. # 江西CCPC省赛-Rng(概率+逆元)

    江西CCPC省赛-Rng(概率+逆元) 题意: 给出一个n,在[1,n]之间选一个R1,在[1,R1]之间选一个L1,得到区间[L1,R1],同理获取区间[L2,R2],问两个区间相交的概率对1e9+ ...

随机推荐

  1. Linux上安装服务器监视工具,名为Scout_Realtime。

    如何从浏览器监视Linux服务器和进程指标 在服务器上安装Ruby 1.9.3+ sudo yum -y install rubygems-devel 在Linux系统上安装了Ruby之后,现在可以使 ...

  2. Set代码

    现有一整数集(允许有重复元素),初始为空.我们定义如下操作:add x 把 x 加入集合del x 把集合中所有与 x 相等的元素删除ask x 对集合中元素x的情况询问 对每种操作,我们要求进行如下 ...

  3. CodeForce-702C Cellular Network(查找)

    Cellular Network CodeForces - 702C 给定 n (城市数量) 和 m (灯塔数量): 给定 a1~an 城市坐标: 给定 b1~bm 灯塔坐标: 求出灯塔照亮的最小半径 ...

  4. 大学四年的Python学习笔记分享之一,内容整理的比较多与仔细

    翻到以前在大学坚持记录的Python学习笔记,花了一天的时间整理出来,整理时不经回忆起大学的时光,一眨眼几年就过去了,现在还在上学的你们,一定要珍惜现在,有个充实的校园生活.希望这次的分享对于你们有学 ...

  5. PHP中操作任意精度大小的GMP扩展学习

    对于各类开发语言来说,整数都有一个最大的位数,如果超过位数就无法显示或者操作了.其实,这也是一种精度越界之后产生的精度丢失问题.在我们的 PHP 代码中,最大的整数非常大,我们可以通过 PHP_INT ...

  6. python风格对象

    对象表示形式 python提供了两种获取对象字符串表示形式的标准方式 repr()         //便于开发者理解的方式返回对象的字符串表示形式(一般来说满足obj==eval(repr(obj) ...

  7. 12306抢票算法居然被曝光了!!!居然是redis实现的

    导读 相信大家应该都有抢火车票的经验,每年年底,这都是一场盛宴.然而你有没有想过抢火车票这个算法是怎么实现的呢? 应该没有吧,咱们今天就来一一探讨.其实并没有你想的那么难 bitmap与位运算 red ...

  8. disruptor笔记之五:事件消费实战

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  9. Go变量与基础数据类型

    一.基础介绍 Go 是静态(编译型)语言,是区别于解释型语言的弱类型语言(静态:类型固定,强类型:不同类型不允许直接运算) 例如 python 就是动态强类型语言 1.Go 的特性: 跨平台的编译型语 ...

  10. 通过Git在本地局域网中的两台电脑间同步代码

    0.前言 一般情况下同步代码可以通过在GitHub/GitLab等网站新建远程仓库,所有机器都向仓库推送或者从仓库下拉更新. 上述过程步骤也不算复杂,不过有时候我们考虑到仓库的安全性等因素,只想在局域 ...