题目链接

Problem A. Drill Wood to Make Fire

S * V >= n即可

#include<bits/stdc++.h>

#define int long long
#define endl '\n' using namespace std; const int N = 2010,mod = 1e9 + 7;
int n,s,v; void solve() {
cin >> n >> s >> v;
if(s * v >= n)
cout << 1 << endl;
else cout << 0 << endl;
} int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int h_h = 1;
cin >> h_h;
while(h_h--)solve();
return 0;
}

Problem B. Wonderful Array

发现 = 的个数就是看有多少 ai mod m = 0,< 的个数不好求,那么就考 虑求 > 的个数。 先将所有 ai 对 m 取模,不会影响答案。因为 0 ⩽ bi+1 − bi < m

      bi mod m > bi+1 mod m ⇐⇒ ⌊bi/m⌋ < ⌊bi+1/m⌋

整体考虑的话就会发现,> 的个数就是 ⌊ bn / m ⌋

#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;
priority_queue <int,vector<int>,greater<int> > Q;
void solve()
{
cin >> k;
vector<int> a(k);
for(int i = 0;i < k;i++)
cin >> a[i];
int x;
cin >> n >> m >> x;
for(int i = 0;i < k;i++)
a[i] %= m;
int sum = x % m;
int num = 0;
for(int i = 0;i < k;i++)
num += a[i];
sum += n / k * num;
for(int i = 0;i < n % k;i++)
sum += a[i];
cout << n - sum / m << 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;
} /* */

Problem I. Tree

我们对每个点直接维护答案,发现对于操作 1,路径上两个端点之外的点 答案不变。因此操作 1 直接对两个端点异或上这个数,操作 2 直接输出 即可。

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; const int N = 1e6+10, mod = 1e9 + 7; //typedef long long ll;
typedef pair<int,int> PII;
int n,m,t,k;
map<int,int> mp;
priority_queue<int> QQ;
deque<int> Q;
void solve() {
cin >> n >> m;
vector<PII> a[n + 1];
vector<int> sum(n + 1,0);
for(int i = 1;i < n;i++){
int x,y,z;
cin >> x >> y >> z;
a[x].push_back({y,z});
a[y].push_back({x,z});
}
for(int i = 1;i <= n;i++){
for(auto j : a[i])
sum[i] ^= j.second;
}
while(m--){
int op;
cin >> op;
if(op == 1){
int x,y,z;
cin >> x >> y >> z;
sum[x] ^= z;
sum[y] ^= z;
}
else{
int x;
cin >> x;
cout << sum[x] << 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();
return 0;
}
/* */

Problem J. Function

给出一个正整数 n(1 ⩽ n ⩽ 105 ) 和 n 个二次项系数为 1 的二次函数,第 i 个函数形如 y = (x − i) 2 + bi(1 ⩽ bi ⩽ n)

然后给出一个正整数 m(1 ⩽ m ⩽ 105 ),表示操作总数。

操作共有两种,第一种是添加一个二次项系数为 1 的二次函数,形如 y = (x − a) 2 + b(1 ⩽ a, b ⩽ n)。第二种是询问所有二次函数在 x = a(1 ⩽ a ⩽ n) 处的最小函数值

。 具体的,每次操作会先给出操作的类型,如果是 0 表示是第一种操作,如 果是 1 表示是第二种操作。对于第一种操作,会再给出两个正整数 a, b。 对于第二种操作,则会再给出一个正整数 a。

查询 x = a 时函数的最小值,容易发现可能为最小值的函数只可能在左右 根号的范围内。 那么只要在左右根号的范围内枚举所有函数,找出最优的即可。

#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
#define LB long double using namespace std; const int N = 1000000000, mod = 1e9 +7; //typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<char, int > mp;
//priority_queue <LB,vector<LB>,less<LB> > Q;
int n,m,t,k;
/* */
string s;
void solve()
{
cin >> n;
vector<int> b(n + 1);
for(int i = 1;i <= n;i++)
cin >> b[i];
int sn = sqrt(n);
int q;
cin >> q;
while(q--){
int op;
cin >> op;
if(op){
int x;
cin >> x;
int res = LONG_LONG_MAX;
for(int i = x - sn; i <= sn + x + 1;i ++){
if(i >= 0 && i < n && b[i])
res = min(res, (i - x) * ( i - x) + b[i]);
}
cout << res << endl;
}
else{
int x,y;
cin >> x >> y;
if(b[x])
b[x] = min(y, b[x]);
else
b[x] = y;
}
}
}
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;
}

Problem K. Split

实际上就是先对n个数的差进行预处理,排序后求一个前缀和,操作0时对于这个差值是不会产生任何改变的,操作1时给一个整数k,则n - k - 1的前缀和.

#include<bits/stdc++.h>
using namespace std; int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for(int i = 0;i < n;i ++)
cin >> a[i];
int q;
vector<int> ve;
for(int i = 1;i < n;i ++){
int x = abs(a[i] - a[i - 1]);
ve.push_back(x);
}
sort(ve.begin(),ve.end());
map<int,int> mp;
for(int i = 0;i < ve.size();i++){
if(i == 0)
mp[i] = ve[i];
else
mp[i] = ve[i] + mp[i - 1];
}
cin >> q;
while(q--){
int op;
cin >> op;
if(!op){
int x;
cin >> x;
a[x - 1] = a[x] + a[x - 2] - a[x - 1];
}
else{
int k;
cin >> k;
cout << mp[n - k - 1] << endl;
}
}
return 0;
}
/* */

Problem L. Zhang Fei Threading Needles - Thick with Fine

输出n - 1即可

#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 = 1e9 + 10, mod = 1e9 +7; //typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<char, int > mp;
//priority_queue <int,vector<int>,greater<int> > q2;
int n,m,t,k;
/* */
string s;
vector<PII> a,ans;
void solve()
{
cin >> n;
cout << n - 1 << 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();
return 0;
}

SMU Spring 2023 Contest Round 5(2023 (ICPC) Jiangxi Provincial Contest -- Official Contest)的更多相关文章

  1. HYNB Round 8: 2016 ICPC Amritapuri Regionals

    HYNB Round 8: 2016 ICPC Amritapuri Regionals A - Tim and BSTs 做法 经典的树 DP 问题. \(dp[u][i]\) 表示考虑以 u 为根 ...

  2. Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest

    Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以 ...

  3. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

  4. 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  8. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  9. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  10. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

随机推荐

  1. c++引用(REFERENCES)

    一个例子 void add(int value) { value++; } int main() { int a = 5; LOG(a); add(a); LOG( a); } 在这种情况下,变量a在 ...

  2. .NET 个人博客-首页排版优化

    个人博客-首页排版优化 优化计划 置顶3个且可滚动或切换 推荐改为4个,然后新增历史文章,将推荐的加载更多放入历史文章,按文章发布时间降序排列. 标签功能,可以为文章贴上标签 推荐点赞功能 本篇文章优 ...

  3. .NET6 个人博客-推荐文章加载优化

    个人博客-推荐文章加载优化 前言 随着博客文章越来越多,那么推荐的文章也是越来越多,之前推荐文章是只推荐8篇,但是我感觉有点少,然后也是决定加一个加载按钮,也是类似与分页的效果,点击按钮可以继续加载8 ...

  4. 记录.Net部署Docker-v指令使用

    记录Docker的-v指令使用 前言 之前我浅学了一下docker,方便部署.net项目(部署的是打包之后的项目) dockerfile文件如下: FROM mcr.microsoft.com/dot ...

  5. Linux内核驱动:cdev、misc以及device三者之间的联系和区别

    Linux内核驱动:cdev.misc以及device三者之间的联系和区别 背景 我想在cdev中使用dev_err等log打印函数,但是跟踪了一下cdev中的原型,发现并不是我想要的. 常见的驱动是 ...

  6. 高通Android UEFI XBL 代码流程分析

    高通Android UEFI XBL 代码流程分析 背景 之前学习的lk阶段点亮LCD的流程算是比较经典,但是高通已经推出了很多种基于UEFI方案的启动架构. 所以需要对这块比较新的技术进行学习.在学 ...

  7. C++ 史上首次超越 C,Python 第二!

    TIOBE 公布了 2024 年 6 月的编程语言排行榜--C++ 史上首次超越 C,跃至榜二,仅次于 Python. C++ 是一种广泛应用于嵌入式系统.游戏开发和金融交易软件等领域的语言,在本月成 ...

  8. java中的即时编译(JIT)简介

    Java发展这么多年一直长青,很大一部分得益于开发人员长期对其坚持不懈的优化:写得更少,跑得更快!JIT就是其中一项十分重要的优化. JIT全程Java Intime Compiler,即Java即时 ...

  9. 记一次Redis实施故障

    服务在测试环境运行没问题,部署到生产环境,连redis时报下面的错误: [2022-11-04 00:00:09][org.springframework.scheduling.support.Tas ...

  10. 轻松掌握useAsyncData获取异步数据

    title: 轻松掌握useAsyncData获取异步数据 date: 2024/7/12 updated: 2024/7/12 author: cmdragon excerpt: 摘要:本文详细介绍 ...