首页 > 其他分享 >2022 RoboCom 世界机器人开发者大赛-本科组(省赛)

2022 RoboCom 世界机器人开发者大赛-本科组(省赛)

时间:2023-07-12 15:15:14浏览次数:41  
标签:ch return 2022 int else vector && 省赛 RoboCom

RC-u1 不要浪费金币

#include <bits/stdc++.h>

using namespace std;


int main() {
    ios::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);
    int n , m , res = 0 ;
    cin >> n >> m;
    for( int i = 1 , cnt = 0, x ; i <= n ; i ++ ){
        cin >> x;
        if( cnt + x > m ) cnt = 0 , res ++;
        cnt += x;
    }
    cout << res << "\n";
}

RC-u2 智能服药助手

用桶去维护一下每一种要上一次的服用时间即可。

#include <bits/stdc++.h>

using namespace std;

#define int long long

int32_t main() {
    ios::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);
    int n , m , res = 0 ;
    cin >> n >> m;
    vector<int> T(n+1);
    for( int i = 1 ; i <= n ; i ++ ) cin >> T[i];
    vector<int> last( n+1  , INT_MIN );
    for( int t , k ; m ; m -- ){
        cin >> t >> k;
        for( int x ; k ; k -- ){
            cin >> x;
            if( last[x] + T[x] <= t ) last[x] = t;
            else cout << "Don't take " << x << " at " << t << "!\n";
        }
    }
}

RC-u3 跑团机器人

首先我们根据加减号去划分表达式。

表达式有两种,两种的区分就要看表达式中有没有d,特判一下表达式第一个字符是d的情况。

对于掷骰子的情况,最小就是全 1 最大就是全 y ,对于每一个表达式都计算出他的取值范围就好了。

#include <bits/stdc++.h>

using namespace std;

#define int long long

map<int, int> cnt;

pair<int, int> calc(string s, int tag) {
    if (s.empty()) return make_pair(0, 0);
    int l = 0, r = 0, t = s.find('d');
    if (t < s.size()) {
        int a = 0, b = 0;
        if( t == 0 ) a = 1;
        else
            for (int i = 0; i < t; i++)
                a = a * 10 + s[i] - '0';
        for (int i = t + 1; i < s.size(); i++)
            b = b * 10 + s[i] - '0';
        l = a , r = a * b;
        cnt[b] += a;
    } else {
        for( auto i : s )
            l = l * 10 + i - '0';
        r = l;
    }
    if (tag == 0) swap(l, r), l = -l, r = -r;
    return make_pair(l, r);
}

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    string s, op = "";
    int tag = 1 , ansL = 0 , ansR = 0 ;
    cin >> s;
    s += '+';
    for (auto i: s) {
        if (i == '+' || i == '-') {
            auto [l, r] = calc(op, tag);
            ansL += l , ansR += r;
            op = "", tag = (i == '+');
        } else op += i;
    }
    
    for( const auto & [k,v] : cnt)
        cout << k << " " << v << "\n";
    cout << ansL << " " << ansR << "\n";
    return 0;
}

RC-u4 攻略分队

这道题数据量很小,直接用搜索枚举出所有的分队情况,然后题目定义的最优规则判断当前分队情况是否比已经记录的最优分队情况更优。

#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef bitset<3> Node;

int resAV = 0, resAA = 0, resAB = 0, resAC = 0, resBV = 0, resBA = 0, resBB = 0, resBC = 0;
vector<int> v(7), resA, resB;
vector<Node> p(7);

#define update {resA = A, resB = B, resAA = AA, resBA = BA, resAB = AB, resBB = BB, resAC = AC, resBC = BC, resAV = AV, resBV = BV;return;}

void dfs(int i, vector<int> A, vector<int> B) {
    if (i > 6) {
        int AV = 0, AA = 0, AB = 0, AC = 0, BV = 0, BA = 0, BB = 0, BC = 0;
        for (auto j: A)
            AV += v[j], AA += p[j][2], AB += p[j][1], AC += p[j][0];
        for (auto j: B)
            BV += v[j], BA += p[j][2], BB += p[j][1], BC += p[j][0];

        // 2
        int r = (resAA > 0 && resBA > 0);
        int n = (AA > 0 && BA > 0);
        if (n == 0) return;
        else if (r == 0) update;

        //1
        r = (resAB > 0 && resAC > 0 && resBB > 0 && resBC > 0);
        n = (AB > 0 && AC > 0 && BB > 0 && BC > 0);
        if (r == 0 && n == 1) {
            update;
        } else if (r == 1 && n == 0)
            return;
        //2
        r = (resAC > 0 && resBC > 0);
        n = (AC > 0 && BC > 0);
        if (r == 0 && n == 1) {
            update;
        } else if (r == 1 && n == 0)
            return;

        //3
        r = abs(resAV - resBV);
        n = abs(AV - BV);
        if (n < r) {
            update;
        } else if (r < n) {
            return;
        }
        //4
        r = (resAV >= resBV);
        n = (AV >= BV);
        if (r == 0 && n == 1) {
            update;
        } else if (r == 1 && n == 0) {
            return;
        }
        //5
        if (A < resA) {
            update;
        } else if (resA < A) {
            return;
        }
        return;
    }
    if (v[i] == 0) {
        dfs(i + 1, A, B);
        return;
    }

    A.push_back(i);
    dfs(i + 1, A, B);
    A.pop_back();

    B.push_back(i);
    dfs(i + 1, A, B);
    B.pop_back();

    return;
}

int32_t main() {
    for (int i = 1; i <= 6; i++)
        cin >> v[i];
    for (int i = 1; i <= 6; i++)
        cin >> p[i];

    int totalA = 0;
    for (int i = 1; i <= 6; i++)
        totalA += p[i][2];
    if (totalA < 2) {
        cout << "GG\n";
        return 0;
    }


    dfs(1, vector<int>(), vector<int>());

    for (auto i: resA)
        cout << i << " \n"[i == resA.back()];
    for (auto i: resB)
        cout << i << " \n"[i == resB.back()];
    return 0;
}

RC-u5 树与二分图

这题感觉很简单吧,首先树一定是二分图。并且把节点按照深度的奇偶性就能很轻松的分开,若奇数深度点的数量为\(A\),偶数深度点的数量为\(B\),则边数最多是\(A\times B\),树本身已经链接\(n-1\)条边,所以答案就是\(A\times B - n + 1\)

#include <bits/stdc++.h>

using namespace std;

#define int long long

vector<vector<int>> e;
int A , B;

int read() {
    int x = 0, f = 1, ch = getchar();
    while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
    if (ch == '-') f = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

void dfs( int x , int p , int fa ){
    if(p) A ++;
    else B ++;
    for( auto y : e[x] )
        if( y != fa ) dfs( y , p^1 , x );
    return ;
}

int32_t main() {
    int n  = read();
    e = vector<vector<int>> (n+1);
    for( int t = n-1 , x , y ; t ; t -- )
        x = read() , y = read() , e[x].push_back(y) , e[y].push_back(x);

    dfs( 1 , 1 , -1 );

    cout << A * B - n + 1ll << "\n";
    return 0;
}

标签:ch,return,2022,int,else,vector,&&,省赛,RoboCom
From: https://www.cnblogs.com/PHarr/p/17547517.html

相关文章

  • [VLDBJ 2022]Privacy and efficiency guaranteed social subgraph matching
    Privacyandefficiencyguaranteedsocialsubgraphmatching动机目标是在不影响查询处理的同时保护隐私其中的子图匹配算法PGP查询会先被分解为星形结构(11行),拿这些分解得到的子图去做匹配实验数据集三个N分别表示类型、属性和标签数量。待补充......
  • C/C++2022级C语言课程设计任务书[2023-07-06]
    C/C++2022级C语言课程设计任务书[2023-07-06]2022级C语言课程设计任务书【题目1】学籍管理系统一、设计题目学籍管理系统(用动态结构体数组实现)二、设计内容【题目描述】假设某校学生学籍基本信息主要包括:学号(整型)、姓名(字符数组型)、所在系、班级等,本系统应能对这些......
  • 在WinServer 2022 Core 上安装SCVMM2022和SqlServer2022
    在WindowsServer2022Core上安装SystemCenterVirtualMachineManager(VMM)2022管理服务器和SqlServer2022CU5系统环境如下:OS:windowsserver2022CoreDataCenterDB:SqlServer2022withCU5ADK: Windows11版本22H2的ADK: https://learn.microsoft.com/zh-cn/wi......
  • 百度之星2022
    课程安排根据标签『裴蜀定理』猜结论:若\(\existst[i]\net[j]\)则一定冲突证明:\(s[i]+t[i]\cdotx=s[j]+t[j]\cdoty\Leftrightarrowt[i]\cdotx-t[j]\cdoty=s[j]-s[i]\)一定有整数解\(t\)都相等的话把区间平移到\([0,t)\)判交和算\([0,10^{18}]\)中长度即可三个因......
  • [ICDE 2022]How Learning Can Help Complex Cyclic Join Decomposition
    [ICDE2022]HowLearningCanHelpComplexCyclicJoinDecomposition总结主要贡献是把子图匹配策略的cost的判断改为了GNN实现的预测(写得挺模棱两可的)动机解决子图匹配的一个重要问题是解决复杂循环连接查询。文章除了在工程方面提供了GUI,主要的贡献是设计了合理的框架,使用A......
  • 2022 年百度之星程序设计初赛三
    packagePTACZW;//随机函数//输入一个n;//随机出项1~n的数importjava.util.Scanner;importjava.util.Random;importjava.util.Set;importjava.util.HashSet;importjava.util.ArrayList;publicclassMain{publicstaticvoidmain(String[]args){......
  • 2023 江苏省赛
    题目链接B对于\(n\)对关系,反过来考虑\(b_{i}>b{i+1}\)的个数观察\(bn\)的形式:\(x,\x+a_{0},\x+a_{0}+a_{1}\,\....,\x+a_{0}+...+a_{n-1}\)其中\(x,a_{i}\)均为模\(m\)后数,相当把外层取模内置(一定要算取模后的,不然后面的证明......
  • 测试机选购机型参考(2022年)
    之前因为公司需要新购买测试机,于是整理了下参考,这里记录下。思路收集:操作系统:iOS,安卓,鸿蒙,win系统版本:iOS(15,14,最低13),安卓(11,10,最低8),鸿蒙(3.0)手机厂商:苹果,三星,华为,荣耀,小米,红米,vivo,oppo,一加,realme,魅族屏幕比:小屏(4.*,4.7),中屏(5.*,5.8),大屏(6.*,6.7)屏幕样式:全面屏,刘海屏,水滴屏,挖孔屏,曲......
  • Unity 2022 LTS 在Mac上打不开
    问题描述:macm1安装后无法打开提示:Licenseerror解决办法:卸载原来下载的unity,在com站点下载UnityHub,登录......
  • 【专题】2022中国新能源汽车内容生态趋势洞察报告PDF合集分享(附原数据表)
    车内容的网络用户和中国新能源汽车企业为研究对象,选择了与新能源汽车有关的网络内容(图片,直播,视频,用户评价),并与中国新能源汽车产业的生产和销售数据相结合,展开了一项调查(查看文末了解报告PDF版本免费获取方式)。当前,新能源汽车已经成为推动汽车行业销量的主要动力,同时,国内自主品牌......