题目
戳这里看题目,密码:na87
丧心病狂的你居然想看我们的成绩
可(Tao)爱(Yan)的YK学长没有写题解
那就只能听我口糊了QAQ
T1 SCALE
求每一步都满足坐盘不轻于右盘的方案数
对n,考虑从n-1转移
将n-1中任意一种方案,每一步放置的砝码的质量×2,得到一个新的合法的序列,且这个序列中不包含质量为1的砝码
这时质量为1的砝码可以在任何一步放在任何一个盘子里
等等,好像有什么不对
第一步不能放在右盘里哦
所以对于n-1的每一种方案,都有(2*i-1)种放1的方法
故f[i] = f[i-1] * (2i-1)
关于此题的详细吐槽见尾声
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long
const ll mod = 20110719ll;
ll n, ans;
int main(){
freopen("scale.in", "r", stdin);
freopen("scale.out", "w", stdout);
scanf("%I64d", &n);
ans = 1ll;
for(ll i = 2; i <= n; i++) {
ans *= i * 2ll - 1ll;
ans %= mod;
}
printf("%I64d\n", ans);
return 0;
}
T2 WIE
这道题全场没有人A
四年前也没有人A
先考虑30分的做法,f[l][r]表示检查区间[l,r]的最坏时间,区间dp做到
n3
的转移
100分用二分+二维树状数组优化
重复一遍,全场没人A,四年前,也没人A
30分
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2005;
int N;
int c[MaxN];
int s[MaxN][MaxN];
int main() {
freopen("wie.in", "r", stdin);
freopen("wie.out", "w", stdout);
scanf("%d", &N);
memset(c, 0, sizeof(c));
memset(s, 0, sizeof(s));
for (int k = 1; k <= N; ++ k) {
scanf("%d", &c[k]);
s[k][k] = c[k];
}
for (int i = N - 1; i >= 1; -- i)
for (int j = i + 1; j <= N; ++ j) {
s[i][j] = min(c[i] + s[i + 1][j], c[j] + s[i][j - 1]);
for (int k = i + 1; k <= j - 1; ++ k)
s[i][j] = min(s[i][j], c[k] + max(s[i][k - 1], s[k + 1][j]));
}
printf("%d\n", s[1][N]);
return 0;
}
100分
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2005;
int N;
int t[MaxN];
int s[MaxN][MaxN];
struct bit {
int c[MaxN];
void clear() {
memset(c, 0x7f, sizeof(c));
}
void insert(int idx, int pos) {
if (pos > N || pos < 1) return;
for (int k = pos; k <= N; k += (k & (-k)))
c[k] = min(c[k], idx);
}
int query(int pos) {
int res = c[pos];
if (pos > N || pos < 1) return 1 << 30;
for (int k = pos; k > 0; k -= (k & (-k)))
res = min(res, c[k]);
return res;
}
} p[MaxN], q[MaxN];
int main() {
freopen("wie.in", "r", stdin);
freopen("wie.out", "w", stdout);
scanf("%d", &N);
memset(t, 0, sizeof(t));
for (int k = 1; k <= N; ++ k) {
scanf("%d", &t[k]);
p[k].clear();
q[k].clear();
s[k][k] = t[k];
p[k].insert(t[k], N + 1 - k);
q[k].insert(t[k], k);
s[k][k - 1] = s[k + 1][k] = 0;
}
for (int k = 1; k <= N; ++ k) {
if (k < N) p[k].insert(t[k + 1] + s[k][k], N - k);
if (k > 1) q[k].insert(t[k - 1] + s[k][k], k - 1);
}
for (int i = N - 1; i > 0; -- i)
for (int j = i + 1; j <= N; ++ j) {
int l = i, r = j;
while (l < r - 1) {
int m = (l + r) >> 1;
if (s[i][m - 1] > s[m + 1][j]) r = m; else l = m;
}
int k = r;
while (k >= l && s[i][k - 1] > s[k + 1][j]) -- k;
s[i][j] = min(p[i].query(N - k), q[j].query(k));
if (j < N) p[i].insert(t[j + 1] + s[i][j], N - j);
if (i > 1) q[j].insert(t[i - 1] + s[i][j], i - 1);
}
printf("%d\n", s[1][N]);
return 0;
}
T3 PATH
非常裸的最短路题,把最短路图建出来,在最短路图里的边全部删掉,对剩余的图再做一边单源最短路
好多人都炸了呢
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long
const int inf = 2000000000;
const int N = 15000, M = 300000;
struct edge{
int from, to, len, nxt;
}e[M * 2], g[M * 2];
int inq[N], head[N], head2[N], dist1[N], dist2[N], dist3[N];
int n, m, s, t, tail = 0;
void add_e(int x, int y, int z) {
e[++tail].from = x;
e[tail].to = y;
e[tail].len = z;
e[tail].nxt = head[x];
head[x] = tail;
}
void add_g(int x, int y, int z) {
g[++tail].from = x;
g[tail].to = y;
g[tail].len = z;
g[tail].nxt = head2[x];
head2[x] = tail;
}
void spfa(int s, int t, int dist[], edge e[]) {
rep(i, 1, n) dist[i] = inf;
memset(inq, 0, sizeof(inq));
queue<int> q;
q.push(s); dist[s] = 0; inq[s] = 1;
while(!q.empty()) {
int u = q.front(); q.pop();
inq[u] = 0;
for(int i = head[u]; i != -1; i = e[i].nxt) {
int v = e[i].to;
if (dist[u] + e[i].len < dist[v]) {
dist[v] = dist[u] + e[i].len;
if (!inq[v]) {
inq[v] = 1;
q.push(v);
}
}
}
}
}
void makegraph() {
int minlen = dist1[t];
tail = 0;
rep(u, 1, n) {
for(int i = head[u]; i != -1; i = e[i].nxt) {
int v = e[i].to;
if (dist1[u] + dist2[v] + e[i].len == minlen || dist2[u] + dist1[v] + e[i].len == minlen)
continue;
add_g(u, v, e[i].len);
}
}
rep(i, 1, n) head[i] = head2[i];
}
int main(){
freopen("path.in", "r", stdin);
freopen("path.out", "w", stdout);
scanf("%d%d", &n, &m);
rep(i, 1, n) head[i] = head2[i] = -1;
rep(i, 1, m) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
add_e(x, y, z);
add_e(y, x, z);
}
scanf("%d%d", &s, &t);
spfa(s, t, dist1, e);
spfa(t, s, dist2, e);
makegraph();
spfa(s, t, dist3, g);
if (dist3[t] == inf) printf("-1\n");
else printf("%d\n", dist3[t]);
return 0;
}
T4 DOME
手推一下可以发现,过定点的圆锥的体积,关于该圆锥的高的函数,是单!峰!的!
自然想到用三分法
用相似三角形就可以通过定点和高算出底面半径
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long
const double eps = 1e-10;
const int N = 15000;
struct point{
double x, y, z;
}p[N];
int n;
double hh;
double getr(double h) {
double r = sqrt(p[1].x * p[1].x + p[1].y * p[1].y) * h / (h - p[1].z);
rep(i, 2, n) r = max(r, sqrt(p[i].x * p[i].x + p[i].y * p[i].y) * h / (h - p[i].z));
return r;
}
double calc(double h) {
double r = getr(h);
return r * r * h;
}
void solve() {
double L = hh, R = 10000000;
while(L + eps < R) {
double m1 = L + (R - L) / 3;
double m2 = R - (R - L) / 3;
double ans1 = calc(m1), ans2 = calc(m2);
if (ans1 <= ans2) R = m2;
else L = m1;
}
printf("%.3lf %.3lf\n", L, getr(L));
}
int main(){
freopen("dome.in", "r", stdin);
freopen("dome.out", "w", stdout);
scanf("%d", &n);
hh = eps;
rep(i, 1, n) {
scanf("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].z);
hh = max(hh, p[i].z);
}
solve();
return 0;
}
尾声
T1 T3 T4 都A了,T2只写了30分,貌似就rank1了
四年前大致也长这副样子
第一题是2011年IMO的原题!IMO!
当HBH大神告诉我他的“地里大发现”时,我内心几乎是崩溃的
YK恐怕只是想让我们知道,信竞比数竞不知道高明到哪里去了
省赛送分题可以做IMO试题
T3发现有一只高一的C选手,在手写Dijkstra + Heap , 后生可畏啊
T4本来发现所有点可以挪到一个平面上,把凸包都拍完了,结果发现是单峰的,果断弃暗(明)投明(暗)
Johann是蒟蒻,Orz各位神犇