4.17 模拟总结

昨天熬夜了早上起来有点迷糊

整体就那样吧

上节课(4.14)开始算走了4天了

第一题

第一遍开始以为是规律题或者说结论题(ACM黑匣子之后每道字符串题都像结论题淦)

拿大样例推了半个小时 推了个大概 估计能拿40pts 结果真就45pts

10
tltltttlttltlttltttttlttlttlttltltlttlt
tltltlttlttttltltttttlttltltlttltlttlt
ttlttltlttltlttltttltltltltltttlttltlt
ttttltttltttlttttttttttlttltltltlttltt
ltttltttttttltttltlttttttltltttlttlttt
tllltllltltttlltlltlltltltllttlllllllll
llltllllttltlllttltllltlltllttlltllllll
tttltttltltltttlttttltttttltttlttlttlt
lltllttlllllttltllltllltltllllltttttllt
tltlttltltltttltltltttlttttltltltltltla

0 1
0 1
0 1
0 1
1 1
0 0
0 0
0 1
0 0
0 0

先看0 0

0 0几大特点:

1、字符串含有非"t l "元素 必0 0

2、任意两个l相连 必0 0

对于其他的:

3、开头是t 预处理tui = 1, 开头是l 预处理lao = 1;

就这么暴力

原代码 45pts

复制代码
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cstring>
 5 #include <queue>
 6 #include <cmath>
 7 //#define int long long
 8 using namespace std;
 9 inline int read() {
10     int x = 0, f = 1;
11     char c = getchar();
12     while (c < '0' || c > '9') {
13         if (c == '-') f = -1;
14         c = getchar();
15     }
16     while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
17     return x * f;
18 }
19 string s;
20 bool t = 0;
21 bool l = 0;
22 int lao = 1;
23 int tui = 1;
24 int main(){
25     freopen("laotui.in","r",stdin);
26     freopen("laotui.out","w",stdout);
27     int T = read();
28     while(T --){
29         lao = 1;
30         tui = 1;
31         t = 0;
32         l = 0;
33         cin>>s;
34         if(s[0] == 't') tui = 1,t = 1,lao = 0;
35         if(s[0] == 'l') lao = 1,l = 1;
36         for(register int i = 1;i <= s.size() - 1; i ++){
37             if(l && s[i] == 'l'){
38                 printf("0 0\n");
39                 break;
40             }
41             if(s[i] != 't' && s[i] != 'l'){
42                 printf("0 0\n");
43                 break;
44             }
45             if(!t && s[i] == 't') t = 1,l = 0;
46             if(!l && s[i] == 'l') l = 1,t = 0;
47             if(i == s.size() - 1){
48                 printf("%d %d\n",lao,tui);
49             }
50         }
51     }
52     return 0;
53 }
复制代码

题解:

第二题:

上手就是dijiska

显然不对

因为没考虑闪现

看小样例

先把0 2 100加速

然后再dijiska

小样例解决;

那就是 先贪心路程最大的加速掉 然后跑最短路

大样例不对

发现自己写的有向最短

改成无向最短

本来想着是先dij再加速 后来发现这样得写记录最短路径 复杂度撕不开 而且小样例也不对

于是过大样例

结果40pts

复制代码
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cstring>
 5 #include <queue>
 6 #include <cmath>
 7 //#define int long long
 8 using namespace std;
 9 const int M = 1e4 + 5;
10 inline int read() {
11     int x = 0, f = 1;
12     char c = getchar();
13     while (c < '0' || c > '9') {
14         if (c == '-') f = -1;
15         c = getchar();
16     }
17     while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
18     return x * f;
19 }
20 const int MaxM = 5e4 + 10;
21 struct edge{
22     int to, dis, next,num;
23 }e[MaxM];
24 int head[MaxM];
25 int dis[MaxM];
26 bool vis[MaxM];
27 int cnt = 0;
28 int n;
29 int m;
30 int s;
31 int k;
32 inline void add_edge( int u, int v, int d ) {
33     cnt++;
34     e[cnt].dis = d;
35     e[cnt].to = v;
36     e[cnt].next = head[u];
37     e[cnt].num = cnt;
38     head[u] = cnt;
39 }
40 bool cmp(edge a,edge b) {
41     return a.dis > b.dis;
42 }
43 bool Cmp(edge a,edge b){
44     return a.num < b.num;
45 }
46 struct node{
47     int dis;
48     int pos;
49     bool operator <( const node &x )const{
50         return x.dis < dis;
51     }
52 };
53 priority_queue<node> q;
54 inline void dijkstra() {
55     dis[s] = 0;
56     q.push((node) {0, s});
57     while (!q.empty()) {
58         node tmp = q.top();
59         q.pop();
60         int x = tmp.pos;
61         if (vis[x]) continue;
62         vis[x] = 1;
63         for (register int i(head[x]); i; i = e[i].next) {
64             int y = e[i].to;
65             if (dis[y] > dis[x] + e[i].dis) {
66                 dis[y] = dis[x] + e[i].dis;
67                 if (!vis[y]) q.push((node) {dis[y], y});
68             }
69         }
70     }
71 }
72 int main() {
73     freopen("overwatch.in", "r", stdin);
74     freopen("overwatch.out", "w", stdout);
75     n = read();
76     m = read();
77     k = read();
78     s = 0;
79     fill(dis + 1, dis + 1 + n, 0x7fffffff);
80     for (register int i(0); i <= m - 1; ++i) {
81         register int u = read();
82         register int v = read();
83         register int d = read();
84         add_edge(u, v, d);
85         add_edge(v, u, d);
86     }
87     if (k != 0) {
88         sort(e + 1, e + 1 + cnt, cmp);
89         for (register int i = 1; i <= k; i++) {
90             e[i].dis = 0;
91         }
92         sort(e + 1, e + 1 + cnt, Cmp);
93     }
94     dijkstra();
95     cout << dis[n - 1] << endl;
96     return 0;
97 }
复制代码

玩过守望先锋的估计会写过吧(bushi

题解:

第三题

好几年前玩过皇室战争(雾

一眼区间dp

时间不够了(20分钟)

转移方程瞎推了一波

最开始想两组为一个单位前后选着算

写着写着就成了01背包

小样例不过

把dp打开看 一个正确答案都没有

最后瞎处理了一波

复制代码
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cstring>
 5 #include <queue>
 6 #include <cmath>
 7 #define int long long
 8 using namespace std;
 9 const int M = 1e4 + 5;
10 inline int read() {
11     int x = 0, dp = 1;
12     char c = getchar();
13     while (c < '0' || c > '9') {
14         if (c == '-') dp = -1;
15         c = getchar();
16     }
17     while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
18     return x * dp;
19 }
20 int n;
21 int k;
22 int dp[M][M];
23 int c[M];
24 int e[M];
25 struct A{
26         int w;
27         int v;
28 }a[M];
29 signed main() {
30     freopen("clash.in", "r", stdin);
31     freopen("clash.out", "w", stdout);
32         n = read();
33         k = read();
34         for (register int i(1); i <= n; i++) {
35             a[i].w = read();
36             a[i].v = read();
37             c[i] = c[i - 1] + a[i].v;
38         }
39         for (register int i(1); i <= n - 1; i++) {
40             if (a[i].w + a[i + 1].w <= k) {
41                 dp[i][i + 1] = a[i].v + a[i + 1].v;
42             }
43         }
44         for (register int l(2); l <= n; l += 2) {
45             for (register int i(1); i <= n + 1 - l; i++) {
46                 if (a[i].w + a[i + l - 1].w <= k) dp[i][i + l - 1] = max(dp[i][i + l - 1],dp[i + 1][i + l - 2] + a[i].v +a[i + l - 1].v);
47                 for (register int k(i + 1); k <= i + l - 3; k += 2) dp[i][i + l - 1] = max(dp[i][i + l - 1], dp[i][k] + dp[k + 1][i + l - 1]);
48             }
49         }
50         for (register int i(2); i <= n; i++) {
51             e[i] = e[i - 1];
52             for (register int j = i % 2; j <= i - 2; j += 2) {
53                 e[i] = max(e[i], e[j] + dp[j + 1][i]);
54             }
55         }
56         cout << e[n] << endl;
57         return 0;
58     }
复制代码

果然0分

题解 : 

整体那样吧 图论-bot dp-bot还需要再看一看 

就这样吧

 

posted @   November&&Rain  阅读(91)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示