ABC463 赛后总结

共 720 字
2 分钟

本场 Rating:$1201 \rightarrow 1239 (+38)$。

A 16:9

不予置评。

1
2
3
4
5
6
7
8
9
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n*9==m*16)puts("Yes");
	else puts("No"); 
	return 0;
}

B Train Reservation

我第一次在 B 题用提高级算法?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<bits/stdc++.h>
using namespace std;
map<char,int>p;
int main(){
	int n;
	char c;
	p['A']=0;
	p['B']=1;
	p['C']=2;
	p['D']=3;
	p['E']=4;
	string t;
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		cin>>t;
		if(t[p[c]]=='o'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

C Tallest at the Moment

一开始看错题了,以为是在 $T_i \sim 2 \times T_{i} + \frac{1}{2}$ 时间内,写了个蛆一样的单调队列。

然后在重新读题 $0.00001$ ms 内,我突然反应过来:

不是只用维护一个后缀最大值然后二分吗???

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<bits/stdc++.h>
using namespace std;
int h[300005],l[300005];
int sfmx[300005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",h+i,l+i);
	}
	for(int i=n;i>=0;i--)sfmx[i]=max(sfmx[i+1],h[i]);
	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		int t;
		scanf("%d",&t);
		auto p=upper_bound(l+1,l+n+1,t);
		printf("%d\n",sfmx[p-l]);
	}
	
	return 0;
}

D Maximize the Gap

又是线段覆盖。好久不见。

 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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll inf=0x3f3f3f3f3f3f3f3fll;
vector<pair<ll,ll> >seg;
int n,k;
bool chk(ll d){
	ll lst=-inf;
	int cnt=0;
	for(auto p:seg){
		if(p.second>=lst+d){
			cnt++;
			lst=p.first;
			if(cnt>=k)return true;
		}
	}
	return false;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		ll l,r;
		scanf("%lld%lld",&l,&r);
		seg.push_back({r,l});
	} 
	sort(seg.begin(),seg.end());
	if(!chk(1)){
		puts("-1");
		return 0;
	}
	ll l=1,r=1e9+1,mid;
	while(r>l+1){
		mid=(l+r)>>1;
		if(chk(mid))l=mid;
		else r=mid;
	}
	printf("%lld",l);
}

E Roads and Gates

我一秒就想到了两个超级源点的做法,为什么?因为一个月前刚出了一个建虚拟点的题目。已爽吃。

 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<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >g[200005];
int n,m,y;
long long dis[200005];
bool vis[200005];
void dij(){
	priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>> >p;
	p.push({0,1});
	memset(dis,0x3f,sizeof(dis));
	while(!p.empty()){
		auto t=p.top();
		p.pop();
		long long w=t.first;
		int v=t.second;
		if(vis[v])continue;
		vis[v]=true;
		dis[v]=w;
		for(auto i:g[v]){
			p.push({i.second+w,i.first});
		}
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&y);
	for(int i=1;i<=m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	g[n+1].push_back({n+2,y});
	g[n+2].push_back({n+1,y});
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		g[i].push_back({n+1,x});
		g[n+2].push_back({i,x});
	}
	dij();
	for(int i=2;i<=n;i++)printf("%lld ",dis[i]);
}

F Senshuraku

看完题解之后发现立刻弃掉真是一个明智的选择。这我哪看得懂啊。

G Random Walk Distance

他的概率一直像条蛆!

还有十分钟结束,我想,写不完了,喂给 DeepSeek 看一眼答案吧。

小鲸鱼:

1
时间到了。这题没有简单算法。作为智能助手,我无法提供一个合理的答案,我将会编写一段累加所有 1 ~ n 并计算除法的代码。

那,再问问 Gemini?

你为什么要用莫队啊???

我去看官方题解了。

识别到:

1
...one can apply Mo’s algorithm to compute...

请输入莫队。

Licensed under CC BY-NC-SA 4.0