1024赛后总结
1.成绩
100+60+0+40=200
最后一场了啊啊啊啊啊啊啊啊:(
2.做题过程
T1
因为
考虑怎么算一个截面的贡献。如果截面上的矩形数
因为坐标可能是负的,所以输入的时候偏移一下,加上
其实不用那么麻烦,枚举删哪个矩形,累加一下贡献再容斥一下,减掉
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n, f[2000010][2], ans, ff[2000010];
int mxz, mxyy, mxxx;
vector <int> v[2000010];
struct cube {
int x0, y0, z0, x1, y1, z1;
} a[100010];
int main () {
freopen("cube.in", "r", stdin);
freopen("cube.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].x0 >> a[i].y0 >> a[i].z0 >> a[i].x1 >> a[i].y1 >> a[i].z1;
a[i].x0 += 1e6;
a[i].y0 += 1e6;
a[i].z0 += 1e6;
a[i].x1 += 1e6;
a[i].y1 += 1e6;
a[i].z1 += 1e6;
f[a[i].z0][0]++;
f[a[i].z1 + 1][1]++;
v[a[i].y0].emplace_back(i);
v[a[i].y1 + 1].emplace_back(-i);
mxz = max(mxz, a[i].z1);
mxyy = max(mxyy, a[i].y1);
mxxx = max(mxxx, a[i].x1);
}
LL tmp = 0, sum = 0;
for (int i = 0; i <= mxz; i++) {
sum += f[i][0];
sum -= f[i][1];
if (sum < n - 1) {
tmp = 0;
continue;
}
if (f[i][0] == 0 && f[i][1] == 0) {
ans += tmp;
// cout << ans << "\n";
continue;
}
if (sum == n - 1) {
int mxx = 0, mxy = 0, mnx = 1e9, mny = 1e9;
for (int j = 1; j <= n; j++) {
if (a[j].z0 > i || a[j].z1 < i) continue;
mxx = max(mxx, a[j].x0);
mxy = max(mxy, a[j].y0);
mnx = min(mnx, a[j].x1);
mny = min(mny, a[j].y1);
}
tmp = max(0ll, 1ll * (mnx - mxx + 1) * (mny - mxy + 1));
ans += tmp;
continue;
}
tmp = 0;
int s = 0, tt = 0;
for (int j = 1; j <= mxyy; j++) {
for (auto k : v[j]) {
if (k < 0) {
s--;
} else {
s++;
}
ff[a[abs(k)].x0] += (k > 0 ? 1 : -1);
ff[a[abs(k)].x1 + 1] += (k > 0 ? -1 : 1);
}
if (v[j].size() == 0) {
tmp += tt;
continue;
}
if (s < n - 1) {
tt = 0;
continue;
}
int fuck = 0;
tt = 0;
for (int k = 1; k <= mxxx; k++) {
fuck += ff[k];
if (fuck >= n - 1) {
tt++;
}
}
tmp += tt;
}
ans += tmp;
// cout << ans << "\n";
}
cout << ans;
return 0;
}
T2
因为三条边
#include <bits/stdc++.h>
using namespace std;
int n, q, a[100010], b[100010];
int main () {
freopen("triangle.in", "r", stdin);
freopen("triangle.out", "w", stdout);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
while (q--) {
int l, r;
cin >> l >> r;
for (int i = l; i <= r; i++) {
b[1 + i - l] = a[i];
}
sort(b + 1, b + r - l + 2);
int f = 0;
for (int j = 3; j <= r - l + 1 && !f; j++) {
if (b[j] < b[j - 1] + b[j - 2]) {
f = 1;
}
}
if (f) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return 0;
}
T3
纯暴力就不讲了
T4
写了一个错的贪心,因为
#include <bits/stdc++.h>
using namespace std;
int n, a[1010], ans, mxa, vis[1010];
vector <int> v[1010];
bool cmp (int x, int y) {
return x > y;
}
int main () {
freopen("graph.in", "r", stdin);
freopen("graph.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++) {
for (int j = 1; j < i; j++) {
if ((a[i] & a[j]) == 0) {
v[i].emplace_back(j);
v[j].emplace_back(i);
}
}
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) {
vis[i] = 1;
int mx = 0;
for (auto j : v[i]) {
if (vis[j]) {
mx = max(mx, a[j]);
} else {
vis[j] = 1;
ans += a[i];
}
}
ans += mx;
}
}
cout << ans;
return 0;
}
3.总结
1.心态
一直都很崩,老师说是信心赛要ak,但我写不出题
2.做题
T1想复杂了
3.时间规划
T1时间太多了