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

2025-11-28

CF

Problem - 1766C - Codeforces(1300)(dp)(模拟)

一笔画,要经过所有黑色,并且有且仅有一次
不能经过白色

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=2e5+10;void solve()
{int n;cin >> n;string s[2];cin >> s[0] >> s[1];for (int t = 0; t < 2;t++){int x = t;int flag = 1;for (int i = 0; i < n;i++){if(s[x][i]!='B')flag = 0;if(s[!x][i]=='B')x ^= 1;}if(flag){cout << "YES\n";return;}}cout << "NO\n";
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}

Problem - 295A - Codeforces(1400)(差分)

读题!!!读了老半天。。。
一个是对从l到r+d
还有查询是执行第x到y个操作
所以使用两次差分
第一次计算每个操作的操作次数
第二次计算操作加的数目

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=1e5+10;
LL a[N],b[N];
struct node{int l,r,d;
}e[N];
LL add[N];int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m, k;cin >> n >> m >> k;for (int i = 1; i <= n;i++){cin >> a[i];}for (int i = 1; i <= m;i++){cin >> e[i].l >> e[i].r >> e[i].d;}for (int i = 1; i <= k;i++){LL x, y;cin >> x >> y;b[x]++, b[y + 1]--;}for (int i = 1; i <= m;i++){b[i] += b[i - 1];//算每个操作的操作数add[e[i].l] += b[i] * e[i].d;add[e[i].r + 1] -= b[i] * e[i].d;}for (int i = 1; i <= n;i++){add[i] += add[i - 1];cout << a[i] + add[i] << " ";}
}

Problem - 1389B - Codeforces(dp好题)(1600)

计算k次移动最大总和
dp[i][j],移动到i位置,j次向左移的最大值
当移动次数刚好满足k时,更新ans

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=1e5+10;
int dp[N][6];
int a[N];void solve()
{memset(dp, 0, sizeof dp);int n, k, z;cin >> n >> k >> z;for (int i = 1; i <= n;i++){cin >> a[i];}int ans=0;for (int j = 0; j <= z;j++){for (int i = 1; i <= n;i++){dp[i][j] = dp[i - 1][j] + a[i];if(i&&j!=n){dp[i][j] = max(dp[i][j], dp[i + 1][j - 1] + a[i]);}if(i-1+j*2==k){ans = max(ans, dp[i][j]);}}}cout << ans << endl;
}int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--){solve();}
}
http://www.jsqmd.com/news/54400/

相关文章:

  • Convolutional Neutral Network(CNN网络)
  • 二维偏序(离线二维数点)
  • Product Hunt 每日热榜 | 2025-10-30 - 教程
  • 2025年Q4球墨铸铁管厂家TOP5排行榜:场景适配+成本优化,采购选型指南
  • 2025年Q4中国GEO优化公司权威排行榜:TOP5服务商解锁Deepseek高转化,AI搜索营销新标杆
  • WPF的MVVM模式核心架构与达成细节
  • 2025年12月GPU平台哪家好?权威榜单TOP5 低延迟+动态扩容,企业/开发者核心推荐
  • 敏捷冲刺随笔-2
  • 2025年12月高压固态软启动柜厂家排行榜,技术创新+24小时售后,工业采购测评推荐
  • 力扣160 相交链表 java达成
  • `train_test_split` 是什么?
  • 解决LVGL与FATFS编码格式冲突及外挂字库方案
  • 我是如何用浏览器插件轻松抓取抖音评论并实现精准搜索分析的
  • 重练算法(代码随想录版) day24 - 回溯part3
  • useEffect详解
  • 详解np.random.normal(0, 3, size=x.shape)
  • 代码随想录Day23_回溯_组合.md
  • 详细介绍:【JUnit实战3_21】第十二章:JUnit 5 与主流 IDE 的集成 + 第十三章:用 JUnit 5 做持续集成(上):在本地安装 Jenkins
  • 代码随想录Day24_回溯_复原IP.md
  • 何以为生
  • GraphRAG进阶:基于Neo4j与LlamaIndex的DRIFT搜索实现详解
  • Gemini3疯了!0.09接入Nano Banana Pro 4k画质API(附实战教程)
  • 11/28
  • noip板子
  • Webstorm常用配置
  • 东方博宜OJ 1119:求各位数字之和 ← 循环结构
  • 2025.11.28
  • 10个免费查重降重工具分享,降AIGC率工具
  • Linux_Socket_浅谈UDP - 教程
  • Jetlinks 物联网平台 开源版学习源码分析