前言

更详细题解可以参考咱学长的(

2023 SMU RoboCom-CAIP 选拔赛.zip

A. 小斧头

f_k 表示满足条件的j = k 的(i,j)对的数量.如上图中第四行即为f1至f5的元素,f1 = 1即有(1,1)满足条件,f2 = 2即有(1,2),(2,2)满足条件,后面同理,然后要找到一个last_k,即表示k开始向前和向后a数组或b数组最大值发生改变的地方.

得出f_k = last_k + (b[k] >= a[k]) * (k - last_k)

last_k可以用单调栈求出.

#include  <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; const int N = 1e5 + 10, mod = 1e9 +7; //typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<vector<int>, int > mp;
//priority_queue <int,vector<int>,greater<int> > q2;
int n,m,t,k;
/*
*/
int ans;
void solve()
{
cin >> n;
vector<int> a(n + 1), b(n + 1), c(n + 1),f(n + 1);
for (int i = 1; i <=n ; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n ; ++i) {
cin >> b[i];
}
for (int i = 1; i <= n ; ++i) {
c[i] = max(a[i], b[i]);
}
stack<int> stk1, stk2;
int lst;
for (int i = 1; i <= n ; ++i) {
while(!stk1.empty() && a[i] > c[stk1.top()])
stk1.pop();
while(!stk2.empty() && b[i] > c[stk2.top()])
stk2.pop();
if(b[i] >= a[i]){
if(stk2.empty())
lst = 0;
else
lst = stk2.top();
f[i] = f[lst] + i - lst;
}
else{
if(stk1.empty())
lst = 0;
else
lst = stk1.top();
f[i] = f[lst];
}
ans += f[i];
stk1.push(i);
stk2.push(i);
}
// for(auto i : f)
// cout << i << ' ';
// cout << endl;
cout << ans << endl;
return ;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int Ke_scholar = 1;
//cin >> Ke_scholar ;
while(Ke_scholar--)
solve();
return 0;
}

B. 能不能整除?

蒟蒻只会40分做法,学长的有一百分做法(不过咱没看懂QAQ

 40分:就是去统计一下每种A[i] / A[j]出现的次数

#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f using namespace std;
const int N = 2e3 + 10; //typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<int, int > mp;
int n,m,t,k;
int c;
priority_queue <int,vector<int>,greater<int> > C;
/*
*/
int mod,ans;
vector<int> a;
void solve()
{
cin >> n >> t >> mod;
for(int i = 0;i < n;i ++){
int x;
cin >> x;
a.push_back(x);
}
for(auto i : a){
for(auto j : a)
mp[i / j] ++;
}
for(auto [i,j] : mp){
if(mp.find(t - i) != mp.end()){
ans = (ans + j % mod * (mp.find(t - i)->second % mod)) % mod;
}
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
//cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}

C. 又是一道构造题

实际上就是构造的矩阵中每一个元素是a,b数组中的公因数,构造完后再对该矩阵每行每列的乘积判断一下,不合理直接输出-1退出即可.

#include  <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; const int N = 2e4 + 10, mod = 1e9 +7; //typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<vector<int>, int > mp;
vector<int> a,b;
//priority_queue <int,vector<int>,greater<int> > q2;
int n,m,t,k;
/**/
int ans; void solve()
{
a.clear();
b.clear();
ans = 0;
cin >> n >> m;
vector<vector<int> > ma(n,vector<int>(m,0));
for(int i = 0;i < n; i++){
int x;
cin >> x;
a.push_back(x);
}
for(int i = 0;i < m;i ++){
int x;
cin >> x;
b.push_back(x);
}
auto g = a;
auto gg = b;
for(int i = 0;i < n;i ++){
for(int j = 0;j < m;j ++){
int x = __gcd(a[i],b[j]);
a[i] /= x;
b[j] /= x;
ma[i][j] = x;
}
}
for(int i = 0;i < n;i ++){
int c = 1;
for(int j = 0;j < m;j ++){
c *= ma[i][j];
}
if(c != g[i]){
cout << -1 << endl;
return ;
}
}
for(int i = 0;i < m;i ++){
int c = 1;
for(int j = 0;j < n;j ++){
c *= ma[j][i];
}
if(c != gg[i]){
cout << -1 << endl;
return ;
}
}
for(auto i : ma){
for(auto j : i){
cout << j << ' ';
}
cout << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int Ke_scholar = 1;
cin >> Ke_scholar ;
while(Ke_scholar--){
solve();
cout << endl;
}
return 0;
}

2023 SMU RoboCom-CAIP 选拔赛的更多相关文章

  1. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  2. 2016 ccpc 网络选拔赛 F. Robots

    Robots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  3. Codevs 2296 仪仗队 2008年省队选拔赛山东

    2296 仪仗队 2008年省队选拔赛山东 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 大师 Master 题解 题目描述 Description 作为体育委员,C君负责这次运动 ...

  4. Codevs 2449 骑士精神 2005年省队选拔赛四川

    2449 骑士精神 2005年省队选拔赛四川 时间限制: 1 s 空间限制: 128000 KB 题目等级 : **大师 Master** 题目描述 Description 在一个5×5的棋盘上有12 ...

  5. JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)

    JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划)     B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...

  6. 2013 CSU校队选拔赛(1) 部分题解

    A: Decimal Time Limit: 1 Sec   Memory Limit: 128 MB Submit: 99   Solved: 10 [ Submit][ Status][ Web ...

  7. 1630/2023: [Usaco2005 Nov]Ant Counting 数蚂蚁

    2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 85  Solved: 40[S ...

  8. 「LOJ2000~2023」各省省选题选做

    「LOJ2000~2023」各省省选题选做 「SDOI2017」数字表格 莫比乌斯反演. 「SDOI2017」树点涂色 咕咕咕. 「SDOI2017」序列计数 多项式快速幂. 我们将超过 \(p\) ...

  9. HDU 2023 求平均成绩

    Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU ...

  10. HDU 6447 - YJJ's Salesman - [树状数组优化DP][2018CCPC网络选拔赛第10题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 Problem DescriptionYJJ is a salesman who has tra ...

随机推荐

  1. xshell+ssh+网络+加密

    使用xshell+ssh用于管理linux服务器,大概是目前最为流行的方式. 这个工具和技术涉及到: 计算机网络 加密解密 虽然不是专门的系统工程师,但还是相对频繁使用这套工具,有时候难免遇到一些不知 ...

  2. Kubernetes容器生命周期 —— 钩子函数详解(postStart、preStop)

    1.概述 容器生命周期钩子(Container Lifecycle Hooks)监听容器生命周期的特定事件,并在事件发生时执行已注册的回调函数. 钩子函数能够感知自身生命周期中的事件,并在相应的时刻到 ...

  3. 基于TI Sitara系列AM5728工业开发板——FPGA视频开发案例分享

    前 言 3 1 cameralink_display案例 4 1.1 案例功能 4 1.2 操作说明 4 1.3 关键代码(MicroBlaze) 11 1.4 Vivado工程说明 16 1.5 模 ...

  4. 【VMware vSAN】vSAN Data Protection Part 1:安装部署。

    VMware vSAN 8 U3 中新引入了基于 vSAN ESA 的全新 vSAN Data Protection 功能,借助 vSAN Data Protection 功能,您可以使用在 vSAN ...

  5. 小组合作实现的基于 jsp,servlet,mysql 编写的学校管理系统

    基本完成的页面--源代码在<文件>中可下载 文件地址:https://i.cnblogs.com/Files.aspx 学生管理模块各功能已实现 百度网盘下载地址: 链接:https:// ...

  6. 韦东山freeRTOS系列教程之【第六章】信号量(semaphore)

    目录 系列教程总目录 概述 6.1 信号量的特性 6.1.1 信号量的常规操作 6.1.2 信号量跟队列的对比 6.1.3 两种信号量的对比 6.2 信号量函数 6.2.1 创建 6.2.2 删除 6 ...

  7. 基于 tc 指令的网速限制工具

    前言 最近有一个需求,需要限制网卡速度进行一些测试.在朋友推荐下阅读了这篇文章 TC简单粗暴限制网速. 经过尝试,简单有效,整理成脚本放在正文,留作参考. 正文 指令解析(chatgpt 分析) 您提 ...

  8. C# 日期帮助类

    using System; using System.Data; namespace Erp.Ship.Tool { [Serializable] public enum DateInterval { ...

  9. 我跟你说@RefreshScope跟Spring事件监听一起用有坑!

    本文记录一下我在 Spring 自带的事件监听类添加 @RefreshScope 注解时遇到的坑,原本这两个东西单独使用是各自安好,但当大家将它们组合在一起时,会发现我们的事件监听代码被重复执行.希望 ...

  10. JVM学习笔记-如何在IDEA打印JVM的GC日志信息

    若要在Idea上打印JVM相应GC日志,其实只需在Run/Debug Configurations上进行设置即可. 拿<深入Java虚拟机>书中的3-7代码例子来演示,如 1 public ...