专栏文章
题解:AT_abc203_e [ABC203E] White Pawn
AT_abc203_e题解参与者 3已保存评论 2
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @miql2osu
- 此快照首次捕获于
- 2025/12/04 06:33 3 个月前
- 此快照最后确认于
- 2025/12/04 06:33 3 个月前
由于 ,所以可以把有黑格子的行扔到一个 map 里面,然后再用一个 set 存储当前能走到哪些格子。按照题意暴力转移,开两个 vector in 和 out,分别存储哪些格子要删掉,哪些格子要加入。
CPP#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
map<int,vector<int>> Map;
set<int> Set;
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d%d",&x,&y);
Map[x].push_back(y);
}
Set.insert(n);
for(auto i:Map)
{
vector<int> in,out;
for(int j:i.second)
{
if(Set.count(j)) out.push_back(j);
if(Set.count(j-1)||Set.count(j+1)) in.push_back(j);
}
for(int j:out) Set.erase(j);
for(int j:in) Set.insert(j);
}
printf("%d",Set.size());
return 0;
}
相关推荐
评论
共 2 条评论,欢迎与作者交流。
正在加载评论...