0%

广东工业大学(GDUT)2016校赛决赛

http://gdutcode.sinaapp.com/problemset.php?page=2
从1169~1175题

本次代码大多基于 takio 的题解 ,自己看吧。。。
(堆在我的 Github 上了。。。以后题解都不堆网盘了)
本文准备更新一些本人遇到的问题。。。

A 一直没写出来。。。
现在(2016/7/13)终于想起来
又要打怪又要遍历不会处理
简略的也讲不清楚。。。
这个是我根据takio巨的代码改造的 (:з」∠)

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream> 
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

const int N=1001;
bool map[N][N];
struct Monster
{
int id,def,add;
bool operator>(const Monster& a) const
{
return def>a.def;
}
};
vector<Monster> mon[N];
priority_queue<Monster,vector<Monster>,greater<Monster> > M;
bool vis[N];
int cnt[N],father[N];
int T,n,m,atk;

void dfs(int u,int fa)
{
father[u]=fa;
for (int i=0;i<cnt[u];i++)
M.push(mon[u][i]);
if (cnt[u]) return;
for (int i=0;i<n;i++)
if (map[u][i]&&i!=fa) dfs(i,u);
}

bool solve()
{
while (!M.empty()) M.pop();
dfs(0,-1);
while (!M.empty())
{
Monster tmp=M.top();
M.pop();
if (atk<=tmp.def) return 0;
atk+=tmp.add;
int &u=tmp.id;
if (--cnt[u]==0)
{
for (int i=0;i<n;i++)
if (map[u][i]&&i!=father[u]) dfs(i,u);
}
}
return 1;
}

int main()
{
scanf("%d",&T);
while (T--)
{
int x,y,z,i;
scanf("%d%d",&n,&m);
memset(map,0,sizeof(map));
memset(vis,0,sizeof(vis));
for (i=1;i<n;i++)
{
scanf("%d%d",&x,&y);
map[x][y]=map[y][x]=1;
}
for (i=0;i<n;i++) mon[i].clear();
scanf("%d",&atk);
for (i=1;i<=m;i++)
{
scanf("%d%d%d",&x,&y,&z);
Monster tmp={x,y,z};
mon[x].push_back(tmp);
}
for (i=0;i<n;i++)
cnt[i]=mon[i].size();
if (solve()) puts("Oh yes.");
else puts("Good Good Study,Day Day Up.");
}
return 0;
}

B 想到了第一行没想到第二行
更没想到第三行!
至少我考虑了一下直接 DP 是 O(NM) 于是没写
自我感觉不算特别智障

D 两个条件都想到了。。。
但是 tm 把叶子数错了。。。
竟然拿 1<<s 跟 n-s 比。。。_(:з」∠)_

E 没有想到那么机智的做法。。。
拿了个单调栈乱搞。。。太弱智了。。。

F 优化1其实包含于优化2 。。。
也是2、3两个都想到了。。。
但是感觉既然是随机数据2应该没什么卵用。。。
TLE
看题解加了以后快了好多突然想到容斥的复杂度是指数级别的。。。
就算只扔掉一个数时间也能变成一半。。。

咖啡,亦我所需也