10.31 模拟赛

10.31 模拟赛

A LIS

考虑每个数字前从$m$降序构造到$a_i$即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
#define MAXN 300006
int n , m , k;
int A[MAXN];
vector<int> ans;
int main() {
cin >> n >> m >> k;
for( int i = 1 ; i <= k ; ++ i ) scanf("%d",&A[i]);
int lef = n - k;
for( int i = 1 ; i <= k ; ++ i ) {
int cur = m;
while( lef && cur > A[i] ) ans.push_back(cur), -- cur ,-- lef;
ans.push_back( A[i] );
}
if( lef ) return puts("No") , 0;
puts("Yes");
for( auto it : ans ) printf("%d ",it);
}

T2 图论

看到数据范围考虑暴搜,枚举答案(其实也就$2n$)只要倒着枚举以前的边就显然仍然存在。

于是每次加边后进行一下宽搜,每个边只会入队一次,每次扩展是$O(n)$故总复杂度$O(n^3) + O(n^3)$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
#define MAXN 1006
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
int n , m , cnt;
int deg[MAXN] , G[MAXN][MAXN];
queue<pii> Q;
void bfs( int x ) {
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
if (!G[i][j] && deg[i] + deg[j] >= x) Q.push(make_pair(i, j)), G[i][j] = G[j][i] = 1;
while (!Q.empty()) {
pii now = Q.front(); Q.pop();
++ deg[now.fi] , ++ deg[now.se];
++ cnt;
int u = now.first, v = now.second;
for (int i = 1; i <= n; i++)
if (i != u && !G[u][i] && deg[u] + deg[i] >= x)
G[u][i] = G[i][u] = 1 , Q.push(mp(u, i));
for (int i = 1; i <= n; i++)
if (i != v && !G[v][i] && deg[v] + deg[i] >= x)
G[v][i] = G[i][v] = 1 , Q.push(mp(v, i));
}
}
int main() {
cin >> n >> m;
for (int i = 1 , u , v; i <= m; ++ i)
scanf("%d%d", &u, &v) , deg[u]++, deg[v]++ , G[u][v] = G[v][u] = 1 , cnt++;
int all = n * ( n - 1 ) / 2;
for (int i = 2 * n; i >= 0; -- i) {
bfs( i );
if (cnt == all)
return printf("%d\n", i) , 0;
}
}

T3 防御

考虑每个点通过这堵墙投影到$x$轴上一段区间,于是就成了一个区间包含问题(二维偏序)

然后就鸽掉了。。精度误差毒瘤。

文章作者: yijan
文章链接: https://yijan.co/old17/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Yijan's Blog