当前位置: 首页 > news >正文

ICPC 新疆省赛2026

传送门

赛时开出来的

C: Size Comparison

糖丸了模拟题,要求输出Bigger,输出了larger,吃了罚时

点击查看代码
#include<bits/stdc++.h>
using namespace std;using ll=long long ;
const int maxn=2e5+10;using pii=pair<int,int>;
map<char,int>mp;
void solve(){string x,y;cin>>x>>y;int numx=0,lenx=x.length();int numy=0,leny=y.length();bool book=0;for(auto c:x){if(c=='X' && x[0]=='X' ){numx++;}else if(c>='0' && c<='9'){numx=numx*10+(c-'0');}}for(auto c:y){if(c=='X' && y[0]=='X'){numy++;}else if(c>='0' && c<='9'){numy=numy*10+(c-'0');}}//cout<<numx<<" "<<numy<<endl;if(x[lenx-1]==y[leny-1]){if(numx==numy){puts("Equal");}else{char s=x[lenx-1];if(s=='L'){if(numx>numy){puts("Bigger");}else if(numx<numy){puts("Smaller");}else puts("Equal");}else{if(numx<numy){puts("Bigger");}else if(numx>numy){puts("Smaller");}else puts("Equal");}}}else{if(x[lenx-1]=='L'){puts("Bigger");}else if(x[lenx-1]=='M'){if(y[leny-1]!='S'){puts("Smaller");}else{puts("Bigger");}}elseputs("Smaller");}}int main(){int _;cin>>_;while(_--){solve();}	return 0;
}

F: Climbing Taihang Mountains in Snow

一眼秒出思路,经典前缀和,一发入魂

点击查看代码
#include<bits/stdc++.h>
using namespace std;using ll=long long ;
const int maxn=2e5+10;
#define x first
#define y second
using pii=pair<int,int>;
int n;
// const int maxn=2e5+10;
struct node{int h,a,b;
}e[maxn];
ll prea[maxn],preb[maxn];
bool cmp(node a,node b){return a.h<b.h;
}
void solve(){cin>>n;for(int i=1;i<=n;++i)cin>>e[i].h;for(int i=1;i<=n;++i)cin>>e[i].a;for(int i=1;i<=n;++i)cin>>e[i].b;sort(e+1,e+1+n,cmp);ll sumn=0;for(int i=1;i<=n;++i){prea[i]=prea[i-1]+e[i].a;preb[i]=preb[i-1]+e[i].b;}ll ans=0;for(int i=0;i<=n;++i){ans=max(ans,prea[i]+preb[n]-preb[i]);}cout<<ans<<endl;return ;
}int main(){int _;
// 	cin>>_;_=1;while(_--){solve();}	return 0;
}

G: Tidying the Row

在I wa了3发之后,0基础队友发现了他觉得很简单的题,甚至讲出了完整思路,然后直接秒了

点击查看代码
#include<bits/stdc++.h>
using namespace std;using ll=long long ;
const int maxn=2e5+10;
#define x first
#define t second
ll n;
map<int,vector<int>>mp;
void solve(){cin>>n;for(int i=1;i<=n;++i){int x;cin>>x;mp[x].push_back(i);}ll num;ll ans=1e9;vector<int>cnt;for(auto [c,a]:mp){if(a.size()>cnt.size()){cnt=a;num=c;}}for(auto [c,a]:mp){if(a.size()==cnt.size()){
//             cout<<c<<endl;ll l1=a[0],l2=a[0],r1=a[a.size()-1],r2=a[a.size()-1];for(int i=0;i<a.size();++i){if(a[i]==a[i+1]-1){l1=a[i+1]; }else break;}for(int i=a.size()-1;i>0;--i){if(a[i]==a[i-1]+1){r2=a[i-1]; }else break;}
//             cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<endl;ans=min(ans,min(r2-l2,r1-l1));}}cout<<ans<<endl;return ;
}int main(){int _;
// 	cin>>_;_=1;while(_--){solve();}	return 0;
}

I:Elemental Monuments

老实说也是一眼出思路的题,可惜因为没看到数据范围,没看到数据还能是负数wa了好几回
这个时候另一个队友造了极大的数据,发现了要用long long

点击查看代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long ;
const int maxn=2e5+10;#define x first
#define t second
using pii=pair<int,int>;
int n;
// const int maxn=2e5+10;
pii e[maxn];
ll pre[maxn][2];
int s;
int ef(pii x){int l=0,r=n+1;ll p=x.x;while(l<=r){int mid=(l+r)>>1;if(e[mid].x<=p){l=mid+1;}else{r=mid-1;}}return l;
}
void solve(){cin>>n>>s;e[0]={-1e10-1,0};e[n+1]={1e10+1,1};for(int i=1;i<=n;++i)cin>>e[i].x;for(int i=1;i<=n;++i){cin>>e[i].t;pre[i][0]=pre[i-1][0];pre[i][1]=pre[i-1][1];if(e[i].t!=0) continue;if(abs(e[i].x)%2){pre[i][1]++;
//             cout<<"odd";}else pre[i][0]++;}
//    for(int i=1;i<=n;++i){
//         cout<<e[i].x<<" ";
//     }cout<<endl;
//        for(int i=1;i<=n;++i){
//         cout<<e[i].t<<" ";
//     }//     for(int i=1;i<=n;++i){
//         cout<<pre[i][0]<<" ";
//     }
//     cout<<endl;
//     for(int i=1;i<=n;++i){
//         cout<<pre[i][1]<<" ";
//     }
//     cout<<endl;ll ans=0;for(int i=1;i<=n;++i){int t=e[i].t;if(t==1){int l,r;l=ef({e[i].x-2*s,0});r=ef({e[i].x+2*s,0});l=max(l,0ll);r=min(r,n+1);while(e[i].x-2*s>=e[l].x && l<=n) ++l;while(e[i].x+2*s<=e[r].x && r>=1) --r ;//cout<<l<<" "<<r<<endl;if(abs(e[i].x)%2){ans+=pre[r][1]-pre[max(0ll,l-1)][1];}else ans+=pre[r][0]-pre[max(0ll,l-1)][0];//cout<<ans<<endl;}}cout<<ans<<endl;}signed main(){int _;
// 	cin>>_;_=1;while(_--){solve();}	return 0;
}

赛时没开出来的

D:Longest Common Prefix:

挺板的题,因为队友带的板子不全,甚至有书只讲算法不给代码,太神秘了

当时想到了字典树,可惜没板子,而且也不会处理这种区间内的,不过到了最后结束时,注意到可以用离线的做法,随让AI做了一个

点击查看代码
#include <bits/stdc++.h>
using namespace std;using ull = unsigned long long;
const ull base = 131; // 大于3的基数struct Event {int qid;   // 查询编号int delta; // +1 或 -1,表示对答案的增幅ull h;     // 需要观察的前缀哈希
};int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;while (T--) {int n, q;cin >> n >> q;vector<string> s(n + 1);for (int i = 1; i <= n; ++i) cin >> s[i];vector<int> ans(q, 0);vector<vector<Event>> events(n + 2); for (int qid = 0; qid < q; ++qid) {int l, r;string t;cin >> l >> r >> t;ull h = 0;for (char c : t) {h = h * base + (c - '0' + 1);events[l - 1].push_back({qid, -1, h});events[r].push_back({qid, +1, h});}}unordered_map<ull, int> cnt; // 当前拥有某前缀的字符串个for (int i = 1; i <= n; ++i) {ull h = 0;for (char c : s[i]) {h = h * base + (c - '0' + 1);cnt[h]++;}for (auto &ev : events[i]) {int cur_cnt = cnt[ev.h]; // 如果不存在则默认为 0ans[ev.qid] += ev.delta * cur_cnt;}}for (int x : ans) cout << x << '\n';}return 0;
}

赛时应该大部分都是字典树,可持久化字典树这种做法,我提供一个思路

奖牌

依然铜奖,喜提雷蛇鼠标

http://www.jsqmd.com/news/710902/

相关文章:

  • AssetStudio终极指南:3分钟快速提取Unity游戏资源
  • 法律AI突破:澳大利亚LLM在法律检索中的优化与应用
  • 机器人常用通信协议大全_UART、RS-485、CAN、SPI、I2C、PWM、PulseDirection、EtherCAT、Profinet、EtherNetIP、Powerlink、ROS2、D
  • LLM性别偏见评估:Wino Bias测试与实践
  • 仅限首批内测用户公开:Docker AI Toolkit 2026隐藏调试模式启用指南(DEBUG=ai-verbose-2026),3分钟定位nvcr.io镜像拉取超时真实原因
  • Mac终端玩转ext4:不用第三方软件,给U盘换‘心脏’的极客指南
  • AI编程革命:Codex脚本自动化实战指南
  • 数据结构实验一
  • 大模型思维可视化:Qwen3与DeepSeek-R1推理路径对比分析
  • Axure RP中文汉化终极指南:3步实现专业原型设计工具全中文化
  • 直方图管理化技术中的直方图计划直方图实施直方图验证
  • html+css
  • Python多模态AI开发指南:让AI同时理解文字、图片和语音
  • 2026/4/18
  • Ansible安装使用
  • Vue.js中Patch过程处理Input等表单元素状态同步的方案
  • AI智能体编排系统:模块化设计如何提升代码交付质量与效率
  • CodeClash:动态评估语言模型编码能力的竞技平台
  • 如何用NoFences免费打造整洁桌面:新手3分钟快速指南
  • 创新项目实训-个人博客(一)
  • 告别命令行恐惧:在Qt Creator里可视化操作Git,轻松管理你的Gitee仓库
  • 《从反复返工到一次成型:QClaw长任务精准执行指南》
  • 和做工厂系统的印尼老哥,复刻了一套属于 MicroPython 的包管理系统
  • 后续技术路线预告:MyBatisPlus + Redis 专栏开启,业务落地全覆盖
  • VS Code Copilot Next 高级工作流配置:7步构建零手动干预的CI/CD就绪开发环境
  • 别再被行尾符搞崩溃了!Windows/Mac/Linux三平台协作,用git config core.autocrlf input一劳永逸
  • YOLOv5在甲状腺结节超声分割中的实践与优化
  • 作弊行为检测数据集分享(适用于目标检测任务已划分)
  • Nginx反向代理和负载均衡
  • 5分钟解锁虚幻引擎游戏资源宝库:FModel新手完整指南