New Dimensions
我们假设枚举 \(a, b\) 那么我们显然可以发现 \(a^2 + b^2 + c^2 - ab - ab - bc\) 中 \(c\) 越大越好
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 5e3 + 5;
int n, v[N], ans;
signed main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
sort(v + 1, v + n + 1);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
ans = max(ans, v[i] * v[i] + v[j] * v[j] + v[n] * v[n] - v[i] * v[n] - v[i] * v[j] - v[j] * v[n]);
}
}
cout << ans;
return 0;
}
Typographic Kaleidoscope
先别急着说是大水题,我给个 \(HACK\)
###..
.#...
.####
.#.#.
####.
.#.#.
.#.#.
.#...
.#...
你很难将其判成 \(A\),但是他是三个 \(T\).
那么我们正着匹配不行了,考虑一下从右至左,从下至上,你会惊奇的发现,对了!我们如何证明呢我们容易 把\(P + T\) 判成 \(A\), \(T + T\) 判成 \(A 或 P\)......不难发现,都是 \(T\)在捣乱,然而 \(T\) 有一个很明显的特征,就是 \(T\) 的尾巴很长,在判的过程中一定会露出一个尾巴,我们反正匹配,那么就一定会先把尾巴长的拆掉,然后就无法组成 \(A\) 或 \(P\) 了
#include <bits/stdc++.h>
using namespace std;
using Pii = pair<int, int>;
#define int long long
const int N = 1e3 + 10;
int n, m, cnt[4], len[4];
char a[N][N];
Pii d[4][N];
void check(int x, int y, int op) {
for (int i = 1; i <= len[op]; i++) {
int nx = x + d[op][i].first, ny = y + d[op][i].second;
if (nx < 1 || ny < 1) {
return ;
}
if (a[nx][ny] != '#') {
return ;
}
}
cnt[op]++;
for (int i = 1; i <= len[op]; i++) {
int nx = x + d[op][i].first, ny = y + d[op][i].second;
a[nx][ny] = '.';
}
}
signed main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
d[1][1] = {0, -1};
d[1][2] = {-1, -1};
d[1][3] = {-2, -1};
d[1][4] = {-3, -1};
d[1][5] = {-4, 0};
d[1][6] = {-4, -1};
d[1][7] = {-4, -2};
len[1] = 7;
d[2][1] = {0, 0};
d[2][2] = {-1, 0};
d[2][3] = {0, -2};
d[2][4] = {-1, -2};
d[2][5] = {-2, 0};
d[2][6] = {-3, 0};
d[2][7] = {-4, 0};
d[2][8] = {-2, -2};
d[2][9] = {-3, -2};
d[2][10] = {-4, -2};
d[2][11] = {-2, -1};
d[2][12] = {-4, -1};
len[2] = 12;
d[3][1] = {0, -2};
d[3][2] = {-1, -2};
d[3][3] = {-2, 0};
d[3][4] = {-3, 0};
d[3][5] = {-4, 0};
d[3][6] = {-2, -2};
d[3][7] = {-3, -2};
d[3][8] = {-4, -2};
d[3][9] = {-2, -1};
d[3][10] = {-4, -1};
len[3] = 10;
for (int j = m; j >= 1; j--) {
for (int i = n; i >= 1; i--) {
for (int k = 1; k <= 3; k++) {
check(i, j, k);
}
}
}
cout << cnt[1] << " " << cnt[2] << " " << cnt[3];
return 0;
}
标签:10,int,20240906,len,long,.#...,判成
From: https://www.cnblogs.com/libohan/p/18432212