2021 CCPC女生赛

newbie,A了五题铜牌收工
比赛时和队友悠哉游哉做题,想着干饭,最后幸好没滚出铜尾。
贴一下比赛过的代码

队友A的,判断正反方向序列是否符合要求

/***
 * @Author: _Krill
 * @Date: 2021-10-31 09:00:34
 * @LastEditTime: 2021-10-31 09:54:36
 */
#include
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]){
            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>station[i];
    }
    cin>>m;
    if(m>abs(x-y)){
        cout<>bussta[i];
    }
    int fu=func();
    if(fu==0)
        cout<y)
            cout<y)
            cout<

刚看以为是最小生成树,实际上毫无关系。
把所有村庄按费用从大到小排序,依次检查是不是边界,是边界就加两次,否则加一次。

/***
 * @Author: _Krill
 * @Date: 2021-10-31 09:13:24
 * @LastEditTime: 2021-10-31 09:54:45
 */
#include
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

队友A的,求 1 / n

/***
 * @Author: _Krill
 * @Date: 2021-10-31 10:08:07
 * @LastEditTime: 2021-10-31 10:17:15
 */
#include
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>x>>y;
    }
    double ans;
    ans=1.0/n;
    printf("%16f",ans)
}

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
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef pair 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  n || 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 > 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;
}
/***
 * @Author: _Krill
 * @Date: 2021-10-31 09:02:15
 * @LastEditTime: 2021-10-31 18:06:19
 */
#include
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 调出来
补题了

Original: https://www.cnblogs.com/krill/p/15490348.html
Author: 01kkkrill
Title: 2021 CCPC女生赛

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/572372/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 使用Gradle自动创建Java项目结构

    D:\N3verL4nd\Desktop\java>tree 卷 本地磁盘 的文件夹 PATH 列表 卷序列号为 00000200 0006:08B0 D:. ├─.grad…

    Java 2023年5月29日
    078
  • fileUpload上传图片,图片消失

    问题描述 我在Eclipse上运行项目的时候,在我用fileUpload上传图片,等到下一次Tomcat刷新的时候,这个照片就没了,而且点击查看那个文件夹也查看不到有图片文件。 我…

    Java 2023年6月8日
    095
  • Spring系列5:各种属性值依赖注入

    上一篇我们介绍Spring中2种依赖注入的方式: 构造函数注入,主要的标签是 <constructor-arg></constructor-arg> Set…

    Java 2023年6月5日
    084
  • 湖南微音软件×JNPF:对标企业人才,实现员工精细化管理

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Java 2023年6月5日
    0102
  • RocketMq基础 看这一篇就够了

    RocketMQ 编译安装 HelloWorld 官方网站 http://rocketmq.apache.org GitHub https://github.com/apache/…

    Java 2023年6月7日
    092
  • 解决win10安装mysql8.0版本出现starting the server问题的最佳方式

    在安装MySQL的最后一步发生了如下错误: 报:MySQL error 1042: Unable to connect to any of the specified MySQL …

    Java 2023年6月5日
    0129
  • Linux Centos7.5 vsftp 的安装与配置

    安装及配置 安装 sudo yum install vsftpd -y 服务管理 启动服务 service vsftpd start 关闭服务 service vsftpd sto…

    Java 2023年6月15日
    072
  • Buuctf-Web-[HCTF 2018]WarmUp

    前言 刷题地址:https://buuoj.cn/challenges 首先打开是一个笑脸,查看源代码,如下图发现了,一个文件 一.代码分析 发现是一堆代码,需要PHP代码审计,全…

    Java 2023年6月13日
    083
  • Java笔记_web.xml文件

    在JavaEE工程中,web.xml文件是用来初始化配置信息:比如Welcome页面、servlet、servlet-mapping、filter、listener、启动加载级别等…

    Java 2023年6月5日
    094
  • 如何从GitHub上下载部分自己需要的文件

    https://blog.csdn.net/weixin_43298370/article/details/105698073 Original: https://www.cnbl…

    Java 2023年6月5日
    094
  • Java ThreadLocal 与 OOM

    ThreadLocal 实例通常都是 static 类型,用于关联线程和线程上下文。 ThreadLocal 提供线程内的局部变量,不同的线程之间不会相互干扰,这种变量在线程的生命…

    Java 2023年5月29日
    081
  • DeferredResult异步处理spring mvc Demo

    spring mvc同步接口在请求处理过程中一直处于阻塞状态,而异步接口可以启用后台线程去处理耗时任务。简单来说适用场景:1.高并发;2.高IO耗时操作。 Spring MVC3….

    Java 2023年5月29日
    066
  • ElasticSearch–全文检索(一)

    ElasticSearch–全文检索(一) 为什么要用ElasticSearch?它可以解决什么问题? 中文文档:使用聚合分析结果 (bookhub.zone) htt…

    Java 2023年6月5日
    071
  • day04_数组

    学习目标: 1. jvm内存图入门 2. 一维数组的使用 3. 二维数组的使用 4. 数组的内存结构 5. 数组中常见算法 6. 数组中常见的异常 java程序运行在jvm上,jv…

    Java 2023年6月8日
    0133
  • Lowest Common Ancestor of Two Nodes in a Binary Tree

    Reference: http://blog.csdn.net/v_july_v/article/details/18312089 (1) Is the tree a BST or…

    Java 2023年5月30日
    069
  • 图像处理

    绘制图像绘图类 不仅可以绘制几何图形, 还可以绘制图像,绘制图像需要使用 drawImage()方法 ,该方法用来将图像资源显示到绘图上下文中。drawImage()方法 语法: …

    Java 2023年6月9日
    060
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球