//这道题博弈的核心就是不能让后手有一段只能放b而长度不够放a的段,并且先手要放最后一次#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int length[300007];int main(){ ios::sync_with_stdio(false);//多组数据输入cin,cout容易超时 cin.tie(NULL); cout.tie(NULL); int q; cin>>q; wh…
传送门 A. 2048 Game 乱搞即可. Code #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() //#define Local using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e5…
链接: https://codeforces.com/contest/1221/problem/D 题意: You have a fence consisting of n vertical boards. The width of each board is 1. The height of the i-th board is ai. You think that the fence is great if there is no pair of adjacent boards having…
链接: https://codeforces.com/contest/1221/problem/B 题意: You are given a chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board. A knight is a chess pi…
链接: https://codeforces.com/contest/1221/problem/C 题意: You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematici…
链接: https://codeforces.com/contest/1221/problem/A 题意: You are playing a variation of game 2048. Initially you have a multiset s of n integers. Every integer in this multiset is a power of two. You may perform any number (possibly, zero) operations wi…
这道题里线段树用来区间更新(每次给更大的区间加上当前区间的权重),用log的复杂度加快了更新速度,也用了区间查询(查询当前区间向右直至最右中以当前区间端点向右一段区间的和中最大的那一段的和),也用log的复杂度加快了查询速度. #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],y[]; ]; ]; vector<pair<]; ],lz[],mxid[]; long long cm…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long a[300007],b[300007];long long dp[300007][5];long long ans;int main(){ ios::sync_with_stdio(false);//多组数据输入cin,cout容易超时 cin.tie(NULL); cout.tie(NULL); int q; cin>>…
https://codeforces.com/contest/1101/problem/F 题意 有n个城市,m辆卡车,每辆卡车有起点\(s_i\),终点\(f_i\),每公里油耗\(c_i\),可加油次数\(r_i\),每辆卡车的油箱大小一样,每次加油都会加满,在城市之间不能加油,问最小油箱大小能满足每辆卡车顺利到达终点 题解 n<=400,m<=250000,考虑离线处理出任意两个城市能加油k次的最小油耗,然后对于每辆卡车询问 定义dp[l][r][k]为区间[l,r]能分成(k+1)段各…
https://codeforces.com/contest/1155/problem/D 题意 一个n个数的数组\(a[i]\),可以选择连续的一段乘x,求最大连续子序列的值 题解 错误思路:贪心,假如x<0,那么就选择最小的一段乘以x,再求最大连续子序列,因为这一段可能夹着一些很大的正数使得翻转一整段的代价很大,可能单独翻转前半段或者后半段更好 定义\(f[i]\)为以i结尾的最大连续子序列,\(g[i]\)为以i开头的最大连续子序列 假设选择翻转的区间是(l,r),则有\(ans=max(…