mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-11-11 16:59:09 +00:00
Compare commits
2 Commits
c96882f67e
...
e48cc83bfb
| Author | SHA1 | Date | |
|---|---|---|---|
| e48cc83bfb | |||
| 90fee25d70 |
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
# 算法笔记
|
# 算法笔记
|
||||||
|
|
||||||
## P6476 题解易错点
|
## P6476 题解易错点
|
||||||
@ -6,6 +8,11 @@
|
|||||||
2. **清空操作优化**:每次使用后需要清空tot数组,但直接memset会超时,改用标记数组记录修改位置
|
2. **清空操作优化**:每次使用后需要清空tot数组,但直接memset会超时,改用标记数组记录修改位置
|
||||||
3. **下标偏移**:结构体T使用of常量处理负数下标,数组大小需要*2
|
3. **下标偏移**:结构体T使用of常量处理负数下标,数组大小需要*2
|
||||||
4. **状态转移公式**:注意容斥原理的应用,dp[i][j] = 当前三元组数 + 子区间累计值 - 重复部分
|
4. **状态转移公式**:注意容斥原理的应用,dp[i][j] = 当前三元组数 + 子区间累计值 - 重复部分
|
||||||
|
## 找规律
|
||||||
|
* 列出所有规则
|
||||||
|
* 模拟所有样例
|
||||||
|
* 样例不够自己凑
|
||||||
|
|
||||||
## 线性动态规划优化为$O(n\log{n})$方法
|
## 线性动态规划优化为$O(n\log{n})$方法
|
||||||
>如果是递增序列就lower_bound
|
>如果是递增序列就lower_bound
|
||||||
|
|
||||||
|
|||||||
48
src/10/27/P9117.cpp
Normal file
48
src/10/27/P9117.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
const ll maxn = 1e5+7;
|
||||||
|
struct S{
|
||||||
|
ll c,t;
|
||||||
|
inline bool operator<(const S&other)const{
|
||||||
|
return t<other.t;
|
||||||
|
}
|
||||||
|
}h[maxn],l[maxn];
|
||||||
|
ll n,m,q;
|
||||||
|
|
||||||
|
static inline void solve(){
|
||||||
|
std::cin>>n>>m>>q;
|
||||||
|
for(ll i=1;i<=n;i++)h[i]={0,0};
|
||||||
|
for(ll i=1;i<=m;i++)l[i]={0,0};
|
||||||
|
for(ll i=1;i<=q;i++){
|
||||||
|
ll opt,x,c;
|
||||||
|
std::cin>>opt>>x>>c;
|
||||||
|
if(opt==0){
|
||||||
|
h[x]={c,i};
|
||||||
|
}else{
|
||||||
|
l[x]={c,i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(ll i=1;i<=n;i++){
|
||||||
|
for(ll j=1;j<=m;j++){
|
||||||
|
if(h[i].c==0&&l[j].c==0){
|
||||||
|
std::cout<<"0 ";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::cout<<std::max(h[i],l[j]).c<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::iostream::sync_with_stdio(false);
|
||||||
|
std::cin.tie(nullptr);
|
||||||
|
|
||||||
|
ll T;
|
||||||
|
std::cin>>T;
|
||||||
|
while(T--)solve();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user