1 /*
2 _ooOoo_
3 o8888888o
4 88" . "88
5 (| -_- |)
6 O\ = /O
7 ____/`---'\____
8 .' \\| |// `.
9 / \\||| : |||// \
10 / _||||| -:- |||||- \
11 | | \\\ - /// | |
12 | \_| ''\---/'' | |
13 \ .-\__ `-` ___/-. /
14 ___`. .' /--.--\ `. . __
15 ."" '< `.___\_<|>_/___.' >'"".
16 | | : `- \`.;`\ _ /`;.`/ - ` : | |
17 \ \ `-. \_ __\ /__ _/ .-` / /
18 ======`-.____`-.___\_____/___.-`____.-'======
19 `=---='
20 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 AC 护体
22 */
23
24 #include <bits/stdc++.h>
25 #define for_(i,a,b) for (int i = (a); i < (b); i++)
26 #define rep_(i,a,b) for (int i = (a); i <= (b); i++)
27 #define per_(i,a,b) for (int i = (a); i >= (b); i--)
28 #define ll long long
29 #define pii pair<int, int>
30 #define fi first
31 #define se second
32 #define sz(a) (int)a.size()
33 #define all(v) v.begin(), v.end()
34 #define ull unsigned long long
35 #define pb push_back
36 #define CE cout << endl;
37 #define CO cout << "OK" << endl;
38 #define D DEBUG
39 #define DEBUG(x) cerr << #x << '=' << x << endl
40 #define endl '\n'
41 using namespace std;
42 const int maxn = 5e5 + 10, mod = 998244353;// mod = 1949777;
43 const double EPS = 1e-3;
44 int n, m, a, b;
45 int ans[1005][1005];
46 signed main() {
47 #ifdef LOCAL
48 freopen("w.in", "r", stdin);
49 //freopen("w.ans", "w", stdout);
50 #endif
51 ios::sync_with_stdio(false);
52 cin.tie(nullptr);
53 //int tt; cin >> tt; while(tt--) solve();
54 cin >> n >> a >> b;
55 vector<int> v(n);
56 rep_(i, 0, n - 1) cin >> v[i];
57 rep_(i, 0, a + b) {
58 int x = max(0, i - b), y = min(i, a); // 水量总和为i时水箱1的上下界
59 int lo = x, hi = y;
60 per_(j, n - 1, 0) {
61 lo = max(lo + v[j], x);
62 hi = min(hi + v[j], y);
63 }//从水箱1的上下界从后往前,把倒水的过程逆过去,得出有影响的水的上下界
64 int flo = lo, fhi = hi;
65 rep_(j, 0, n - 1) {
66 flo = max(min(flo - v[j], y), x);
67 fhi = min(max(fhi - v[j], x), y);
68 } // 从有影响的水的上下界从前往后模拟倒水,得出答案的水的上下界
69 rep_(j, x, y) {
70 int d = i - j;
71 if (j <= lo) {
72 ans[j][d] = flo; //水箱1水太少,对答案贡献是下界flo
73 } else if (j >= hi) {
74 ans[j][d] = fhi;//太多
75 } else {
76 ans[j][d] = flo + j - lo;
77 //处于有影响范围
78 }
79 }
80 }
81 rep_(i, 0, a) {
82 rep_(j, 0, b) {
83 cout << ans[i][j] << ' ';
84 }
85 cout << endl;
86 }
87 return 0;
88 }

cf1809e(edu145e)的更多相关文章

随机推荐

  1. dpkt 简单应用

    import dpktfrom dpkt.utils import mac_to_str,inet_to_strcap=f'D:/test_pacp/6.pcap'with open(cap,'rb' ...

  2. Component inside <Transition> renders non-element root node that cannot be animated

    原因是transition标签下存在多个根标签 原代码: 解决方法 Suspense还处于试验阶段,可能导致default内容与fallback内容同时存在,导致错误

  3. Navicat连接Mysql报错:Client does not support authentication protocol requested by server(转载)

    Navicat连接MySQL Server8.0版本时出现Client does not support authentication protocol requested  by server:解决 ...

  4. python跨文件之全局变量

    Python中的global关键字,你了解吗? - 知乎 (zhihu.com)  global 关键字 python跟C不一样,c是在一个文件定义后在另一个文件声明下是extern变量就好.pyth ...

  5. ggplot axis text 拐弯

    scale_y_discrete(position = "left",labels=function(x) str_wrap(x, width=48)) +

  6. C/C++ 数据结构单链表的实现(初始化、插入、删除、销毁)

    #include <iostream> #include <Windows.h> #define MAX_SIZE 100 using namespace std; //单链表 ...

  7. 转发:基于Lerna打造多包管理最佳实践之道

    最近在看vue-cli的源码部分,注意到这一个仓库下维护了多个package,很好奇他是如何在一个repo中管理这些package的. 我们组现在也在使用组件库的方式维护项目间共用的业务代码.有两个组 ...

  8. 2021.06.21 onmouseover和onmouseleave事件对比

    在重新巩固js基础的过程中,分别使用onmouseover和onmouseleave事件却导致了不同的效果,但是在之前的记忆中,这两者确实是一样的哈,因此探究一下产生不同效果的原因. 在使用onmou ...

  9. Undelivered Mail Returned to Sender

    电子邮件是使用电子邮件地址application@sample.com从Application发送的. 出于业务原因我们无法在此应用程序中更新/删除无效的外部电子邮件地址,因此响应出站电子邮件会生成许 ...

  10. bilibili视频常用快捷键

    Esc退出全屏 Q点赞.长按三连 W投币 E收藏 D开/关弹幕 F开/关全屏 M静音 [ 多P 上一个 ] 多P下一个 Enter发弹幕 Space播放/暂停 →单次快进5s,长按倍速播放 ←快退5s ...