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. 动态规划精讲(一)LC最长公共子序列

    P1439 [模板]最长公共子序列 题目描述 给出1,2,-,n 的两个排列P1​ 和P2​ ,求它们的最长公共子序列. 输入格式 第一行是一个数 n. 接下来两行,每行为 n 个数,为自然数 1,2 ...

  2. fontawesome图标不显示的原因

    1.查看css路径是否正确 2.查看font文件夹内的字体文件是否引入 3.查看font文件夹内的字体资源路径是否正确

  3. IDL读取fits文件

    使用mrdfits函数 这是天文学标准库中的函数,下载地址:https://idlastro.gsfc.nasa.gov/homepage.html,下载后,将pro文件夹导入到IDL工程中. str ...

  4. MSSQL数据库安全实验

    管理SQL Server认证模式 (1)确认 SQL Server 验证 ①在桌面上单击"开始",选择"程序"→"Microsoft SQL Serv ...

  5. Django框架进阶

    Django ORM那些相关操作 Django中ORM介绍和字段及字段参数 Cookie.Session和自定义分页 Django 中间件 AJAX Django form表单 Django的认证系统 ...

  6. 鸿蒙内核源码分析(重定位篇) | 与国际接轨的对外部发言人 | 百篇博客分析OpenHarmony源码 | v55.01

    百篇博客系列篇.本篇为: v55.xx 鸿蒙内核源码分析(重定位篇) | 与国际接轨的对外部发言人 | 51.c.h.o 加载运行相关篇为: v51.xx 鸿蒙内核源码分析(ELF格式篇) | 应用程 ...

  7. P6499-[COCI2016-2017#2]Burza【状压dp】

    正题 题目链接:https://www.luogu.com.cn/problem/P6499 题目大意 \(n\)个点的一棵树,开始有一个棋子在根处,开始先手选择一个点封锁,然后后手封锁棋子所在点然后 ...

  8. 踩坑系列《五》 Incorrect datetime value: 时间添加失败原因

    在进行单元测试中通过 new Date() 方式添加时间时,报了 Data truncation: Incorrect datetime value:这样的错误(我数据库表的时间类型是 datetim ...

  9. keepalived-master-slave

    Master配置 global_defs { notification_email { root@localhost } notification_email_from keeplived@local ...

  10. Lamport时间戳论文笔记

    本文主要参考文献[1]完成. 声明:本人仅在博客园发表了本文章,笔名LightningStar,其他网站均为转载. 笔记 私以为,论文中作者的核心工作是为分布式系统建立了一种数学模型,并基于这种数学模 ...