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

2025-11-16

Problem - 1924A - Codeforces(构造)

要判断s字符串是否满足是所有前k个字符的子数组
则需要把s分段,每一段都包含前k个字符
如果段数>=n长度,即满足
否则,找最后一段不满足的字符
构造一个不满足的字符串

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=2e5+10;void solve()
{set<char> s;int n, k, m;int cnt = 0;cin >> n >> k >> m;string str,ans;cin >> str;for(auto x:str){s.insert(x);if(s.size()==k){s.clear();cnt++;ans += x;}}if(ans.size()<n){cout << "NO\n";char ch;for (char i = 'a'; i <= 'z';i++){if(!s.count(i)){ch = i;break;}}while(ans.size()<n){ans += ch;}cout << ans << endl;}else{cout << "YES\n";}
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}

Problem - 1547E - Codeforces(dp)(1500)

从前往后推一遍
从后往前推一遍

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=3e5+10;
LL a[N], t[N],dp[N];
LL inf = 1e18;void solve()
{int n, k;cin >> n >> k;for (int i = 0; i < k;i++){cin >> a[i];}for (int i = 0; i <= n;i++){dp[i] = inf;}for (int i = 0; i < k; i++){cin >> t[i];dp[a[i]] = t[i];}for (int i = 2; i <= n;i++){dp[i] = min(dp[i], dp[i - 1] + 1);}for (int i = n - 1; i >= 1;i--){dp[i] = min(dp[i], dp[i + 1] + 1);}for (int i = 1; i <= n;i++){cout << dp[i] << " ";}cout << endl;
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}

Problem - 1976C - Codeforces(贪心)(1600)

贪心,求出n,m+1和n+1,m
然后遍历减去

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=2e5+10;
int a[N], b[N];void solve()
{int n, m;cin >> n >> m;for (int i = 0; i < n + m + 1;i++)cin >> a[i];for (int i = 0; i < n + m + 1;i++)cin >> b[i];LL ca1 = n, cb1 = m + 1, ca2 = n + 1, cb2 = m;LL ans1 = 0, ans2 = 0;for (int i = 0; i < n + m + 1;i++){if(a[i]>b[i]){if(ca1>0){ans1 += a[i];ca1--;}else{ans1 += b[i];cb1--;}if(ca2>0){ans2 += a[i];ca2--;}else{ans2 += b[i];cb2--;}}else{if (cb1 > 0){ans1 += b[i];cb1--;}else{ans1 += a[i];ca1--;}if (cb2 > 0){ans2 += b[i];cb2--;}else{ans2 += a[i];ca2--;}}}int ca = n, cb = m;for (int i = 0; i < n + m + 1;i++){if(ca>0&&cb>0){if(a[i]>b[i]){cout << ans2 - a[i] << " ";ca--;}else{  cout << ans1 - b[i] << " ";cb--;}}else{if(ca==0){cout << ans1 - b[i] << " ";}elsecout << ans2 - a[i] << " ";}}cout << endl;
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}

Problem - 1811E - Codeforces(妙)(思维题)(1500)

初看以为是复杂的数位dp+二分
看了题解发现只要把十进制转化成9进制

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
int x,a[50];
int m[12] = {0, 1, 2, 3, 5, 6, 7, 8, 9};void solve()
{LL n;x = 0;cin >> n;while(n){a[++x] = m[n % 9];n /= 9;}for (int i = x; i >= 1;i--){cout << a[i];}cout << endl;
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}
http://www.gsyq.cn/news/51532.html

相关文章:

  • P14092 [ICPC 2023 Seoul R] M. S. I. S.
  • 【具身智能科普】表格分析核心概念、技术体系、应用场景落地、商业化等 - 指南
  • temperature、top_p、top_k
  • PyCharm gitee: Merge with strategy ort failed.
  • 获取数据,转换成JSON,返回到前端页面
  • 2025年11月副业平台推荐榜:五强生态模式深度解析
  • 完整教程:MySQL 8.0.29 及以上版本中 SSL/TLS 会话复用(Session Reuse)
  • 红队、蓝队与紫队:网络安全攻防演练的三大支柱
  • 2025年11月副业平台评价榜:零门槛生态对比助你安全增收
  • 调整电话交换机 3CX 对接微软 Teams 直接路由
  • Pycharm为什么会自动创建__pycache__
  • 山东大学 计算机图形学实验 二维网格剖分 Catmull-Clark算法
  • 什么是“组态路径”?
  • 深入探索剖析 JVM 的启动过程
  • noip8多校2
  • 2025年11月冷媒剂厂家榜单:五强技术参数与口碑对比评测
  • 工业级时序数据库选型指南:技巧架构与场景化实践
  • 20232429 2025-2026-1 《网络与系统攻防技术》实验五实验报告
  • P5797 [SEERC 2019] Max or Min
  • 完整教程:【论文精读】Latent-Shift:基于时间偏移模块的高效文本生成视频技术
  • (链表)找单链表倒数第k个结点
  • 和为定值的子集数 25-11-16
  • 分布式监控体系:从指标采集到智能告警的完整之道 - 实践
  • hot 100 (1)—— 两数之和(哈希) - 指南
  • Day40(10)-F:\硕士阶段\Java\课程代码\后端\web-ai-code\web-ai-project01\springboot-mybatis-quickstart
  • 还能回到原先吗 绞尽脑汁翻阅文献 这名为爱的实验 被等号连接
  • 2025年11月手动旗杆厂家口碑推荐榜单及选购指南
  • 2025年四川电动旗杆制造厂排行榜TOP5权威发布
  • debian sysctl: cannot open /etc/sysctl.conf: 没有那个文件或目录
  • mysql函数大全及举例 - 详解