首页 > 其他分享 >The 16-th BIT Campus Programming Contest - Onsite Round

The 16-th BIT Campus Programming Contest - Onsite Round

时间:2023-09-07 17:35:07浏览次数:38  
标签:Onsite std 16 int Contest cin long ++ using

链接:https://codeforces.com/gym/104025

A. Gifts in box

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, h;
    cin >> n >> m >> h;

    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> b(h, vector<int>(m));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < n; k++) {
                if (a[k][j] >= i + 1) {
                    b[i][j]++;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < m; j++) {
            cout << b[i][j] << " \n"[j == m - 1];
        }
    }
    return 0;
}

B. BIT Palindrome

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

constexpr int P = 1000000007;

void solve() {
    int n;
    cin >> n;

    if (n == 1) {
        cout << "0\n";
    } else if (n == 2) {
        cout << "3\n";
    } else if (n == 3) {
        cout << "18\n";
    } else {
        cout << 6LL * (n + 1) % P << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

E. Equal

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, y;
    cin >> x >> y;

    if (y >= x) {
        cout << y - x << '\n';
    } else {
        if (y % 2 == x % 2) {
            cout << (x - y) / 2 << '\n';
        } else {
            cout << (x + 1 - y) / 2 + 1 << '\n';
        }
    }
    return 0;
}

G. Get off work

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> g(n);
    vector<int> f(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;

        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    function<void(int, int)> dfs = [&](int cur, int pre) {
        for (auto &nex : g[cur]) {
            if (nex != pre) {
                dfs(nex, cur);
                f[cur] += f[nex];
            }
        }
        if (cur) {
            f[cur]--;
            while (f[cur] < 0) {
                f[cur] += k;
                ans++;
            } 
        }
    };
    dfs(0, -1);
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

H. Happiness Index

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

#include "ext/pb_ds/assoc_container.hpp"

template <typename Key, typename Cmp_Fn = std::less<Key>>
class Set : public __gnu_pbds::tree<Key, __gnu_pbds::null_type, Cmp_Fn,
                                __gnu_pbds::rb_tree_tag,
                                __gnu_pbds::tree_order_statistics_node_update> {};

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto f = [&](int x) {
        Set<pair<i64, int>> s;
        vector<i64> sum(n + 1);
        i64 res = 0;
        for (int i = 0; i <= n; i++) {
            if (i != n) {
                sum[i + 1] = sum[i] + a[i] - x;
            }
            res += s.order_of_key({sum[i] + 1, 0});
            s.insert({sum[i], i});			
        }
        return res;
    };
    cout << f(k) - f(k + 1) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

J. Stones

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

int sg(int x) {
    if (!x) {
        return 0;
    }
    if (x & 1) {
        return (x + 1) / 2;
    }
    return sg(x / 2 - 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;

    for (int i = 0; i < n; i++) {
        ans ^= sg(a[i]);
    }
    cout << (ans ? "Alice" : "Bob") << '\n';
    
    return 0;
}

K. ZYW with tutors

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << "0\n";
    return 0;
}

标签:Onsite,std,16,int,Contest,cin,long,++,using
From: https://www.cnblogs.com/kiddingma/p/17685591.html

相关文章

  • 亚马逊电热水壶认证加拿大CSA22.1和SOR/2016-181标准和要求
    近日,亚马逊平台发布公告,要求在加拿大站销售的所有电水壶必须有ISO17025实验室出具的符合CSA22.1和SOR/2016-181标准的认证证书。卖家们应尽快上传相关资料以避免产品被强制下架,截止日期为2023年10月30日。电水壶作为一种常见的小家电,受到了广大消费者的喜爱。然而,由于安全问题的日......
  • Windows Server 2016 更改远程桌面端口
     WindowsServer2016更改远程桌面端口操作步骤:步骤一:在服务器运行窗口中输入“regedit”打开注册表编辑器。 步骤二:在注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer\Wds\rdpwd\Tds\tcp目录下,修改PortNumber数值,将其修改为你想要的修改的......
  • [题解] AtCoder Beginner Contest 308 A~G
    AtCoderBeginnerContest308A~GA.NewSchemevoidMain(){vector<i64>a(8);for(auto&x:a)cin>>x;if(!is_sorted(a.begin(),a.end())&&!all_of(a.begin(),a.end(),[](auto&x){returnx%25!=0||!(100......
  • 速腾RS16的ROS2驱动
    文章目录本机软硬件环境ROS2驱动下载ROS2编译设置固定IP编辑配置文件测试参考本机软硬件环境ROS2-foxyubuntu20.04速腾RS16ROS2驱动下载mkdirlaser_ws&&cdlaser_ws/mkdirsrc&&cdsrc/gitclonehttps://github.com/RoboSense-LiDAR/rslidar_msg.gitgitclonehttps://g......
  • 【软考】系统集成项目管理工程师(三)信息系统集成专业技术知识①【16分】
    一、系统集成的特点官方解释:1、信息系统建设的内容主要包括设备采购、系统集成、软件开发和运维服务等;2、信息系统集成是指将计算机软件、硬件、网络通信、信息安全等技术和产品`集成`为能够满足用户特定需求的信息系统;显著特点如下:1、信息系统集成要以满足用户需求为根本出发点;2......
  • 用友GRP-U8 Proxy SQL注入 CNNVD-201610-923
    漏洞描述用友GRP-u8存在XXE漏洞,该漏洞源于应用程序解析XML输入时没有进制外部实体的加载,导致可加载外部SQL语句,以及命令执行影响版本用友GRP-U8行政事业内控管理软件(新政府会计制度专版)漏洞复现fofa语法:title="用友GRP-U8行政事业内控管理软件"登录页面:POC:POST/ProxyHT......
  • 高亮LED数码管显示驱动IC-VK16K33/AA/B/BA/C 多种封装 质量稳定 适用于计量插座,数字闹
    概述VK16K33是一种带按键扫描接口的数码管或点阵LED驱动控制专用芯片,内部集成有数据锁存器、键盘扫描、LED驱动模块等电路。数据通过I2C通讯接口与MCU通信。SEG脚接LED阳极,GRID脚接LED阴极,可支持16SEGx8GRID的点阵LED显示面板。最大支持13×3的按键。内置上电复位电路,整体闪烁频......
  • Ubentu 16.04.2 LTS安装mysql,jdk1.8
    一、网络设置1、网络设置sudovim/etc/network/interfaces文件中写入以下内容,写完后wq保存退出。#设置网卡名称autoeth0#设置静态IP,如果是使用自动IP用dhcp,后面的不用设置ifaceeth0inetstatic#设置IP地址addressxxx.xxx.xxx.xxx#设置子网掩码netmaskxxx.xxx.xxx.......
  • png8、png16、png32的区别,以及 png 的压缩原理
    区别PNG8、PNG16、PNG32是PNG图像格式的不同变种,它们主要区别在于颜色深度和透明度支持的不同。PNG8:PNG8是一种8位颜色深度的PNG图像格式,它最多支持256种颜色。对于颜色相对较简单、不需要透明度的图像,使用PNG8可以获得较小的文件大小。PNG8图像使用一种叫做调色板(Pa......
  • 第一节上机课(Visio 2016)
    今天是开学以来的第一节实验上机课 老师给我们布置了三个作业第一个是要写一篇自己的博客第二个就是安装visio第三个就是写教材第19页的习题三个任务完成的都比较顺利我正好也有visio2016的安装包也是非常的幸运安装好自己电脑的visio后还给几个同学提供了安装包和包安......