一
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第1张图片](http://img.e-com-net.com/image/info8/62065dd3687f4f70932366474d442a69.jpg)
简单的签到题全部输出“NO”即可。
#include
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll>P;
const ll maxn = 1e5 + 7;
const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;
ll t, n, x, k,m,from,to;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
cin >> n;
cout << "No\n";
}
return 0;
}
二
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第3张图片](http://img.e-com-net.com/image/info8/35863b1d0c8949268748e23c72155c0d.jpg)
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第4张图片](http://img.e-com-net.com/image/info8/45acacd50d37407db741767c9f7fc042.jpg)
签到题,分段函数,分类讨论。
#include
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll>P;
const ll maxn = 1e5 + 7;
const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;
ll t, n, x, k,m,from,to;
struct node {
ll l, r;
friend bool operator<(node a, node b) {
if (a.r == b.r)return a.l < b.l;
else return a.r < b.r;
}
};
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
cin >> n;
ld ans1 = 0;
ld ans2 = 0;
for (int i = 0; i < n; i++) {
cin >> x;
if (ans1 + x <= 100)ans1 += x;
else if (ans1 + x > 100 && ans1 + x <= 200) {
if (ans1 < 100)ans1 = 100 + (x - (100 - ans1)) * 0.8;
else ans1 += x * 0.8;
}
else if (ans1 + x > 200) {
if (ans1 < 100) {
ld temp =(x - (100 - ans1));
if (temp <= 125)ans1 = 100 + temp * 0.8;
else ans1 = 200 + (temp - 125) * 0.5;
}
else if (ans1 >= 100 && ans1 < 200) {
if (ans1 + x * 0.8 <= 200)ans1 = ans1 + x * 0.8;
else {
ans1 = 200 + (x - (200-ans1)*1.25) * 0.5;
}
}
else ans1 += x * 0.5;
}
if (ans2 < 100)ans2 += x;
else if (ans2 >= 100 && ans2 < 200)ans2 += x * 0.8;
else ans2 += x * 0.5;
}
cout << fixed << setprecision(3) << ans1 << " " << ans2 << "\n";
}
return 0;
}
三
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第6张图片](http://img.e-com-net.com/image/info8/432c05c5dc4148baabb729beb4eee423.jpg)
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第7张图片](http://img.e-com-net.com/image/info8/af8bf7024ffe4f5c874268a141188e8e.jpg)
线性基模板题,稍微变化下。
#include
#include
#define ll long long
using namespace std;
struct Linebasis{
ll p[65], b[65];
int cnt;
bool flag;
void init(){
memset(p, 0, sizeof p);
memset(b, 0, sizeof b);
cnt = 0;
flag = false;
}
bool insert(ll x){
for (int i = 62; i >= 0; i--){
if((x >> i) & 1){
if(!p[i]){
p[i] = x;
break;
}
x ^= p[i];
}
}
if(x)
cnt++;
else
flag = true;
return x > 0;
}
ll querymax(ll x = 0){
ll res = x;
for (int i = 62; i >= 0; i--){
if((res^p[i])>res)
res ^= p[i];
}
return res;
}
} base;
int t, n;
ll tmp;
int main(){
cin.sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> t;
while(t--){
base.init();
cin >> n;
for (int i = 0; i<n; i++){
cin >> tmp;
base.insert(tmp);
}
cout << base.querymax() << endl;
}
return 0;
}
四
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第8张图片](http://img.e-com-net.com/image/info8/aa99291eafb444a9bf0ee355910df48c.jpg)
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第9张图片](http://img.e-com-net.com/image/info8/3015239351494c1f80c0e1a8855f1f40.jpg)
区间dp。
#include
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll>P;
const ll maxn = 1e5 + 7;
const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;
ll t, n, x, k,m,from,to;
struct node {
ll l, r;
friend bool operator<(node a, node b) {
if (a.r == b.r)return a.l < b.l;
else return a.r < b.r;
}
};
ll arr[510];
ll g[510][510], f[510][510];
void init() {
for (int i = 0; i < 510; i++) {
for (int j = 0; j < 510; j++) {
g[i][j] = 0;
f[i][j] = 0;
}
arr[i] = 0;
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
init();
cin >> n >> m;
for (ll i = 1; i <= n; i++)cin >> arr[i];
if (n & 1) {
cout << 0 << "\n"; continue;
}
for (ll i = 0; i <= n; i++)g[i + 1][i] = 1;
for (ll len = 2; len <= n; len += 2) {
for (ll l = 1; l + len - 1 <= n; l++) {
ll r = l + len - 1;
ll e = 0;
if (arr[l] >= 0 && arr[r] <= 0) {
if (arr[l] == 0 && arr[r] == 0)e = m;
else if (arr[l] == 0 || arr[r] == 0 || (arr[l] + arr[r] == 0))e = 1;
else e = 0;
f[l][r] = g[l + 1][r - 1] * e % mod;
}
for (ll k = l; k <= r; k+=2) {
g[l][r] =(g[l][r]+g[l][k-1]*f[k][r]) % mod;
}
}
}
cout << g[1][n] % mod << "\n";
}
return 0;
}
五
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第11张图片](http://img.e-com-net.com/image/info8/489202aa47b544cb91d23c52f641e5f4.jpg)
贪心,当时没想出来,下附jiangly大佬的代码OTZ(题解Ologn,大佬On线性!)
![2022“杭电杯”中国大学生算法设计超级联赛(4)个人记录_第13张图片](http://img.e-com-net.com/image/info8/1f0a4ca4b5a848fcb09ccd8153aec5d8.jpg)