cf1809e(edu145e)
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 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】