Offer收割赛26赛后题目直播讲解

0
0

我们会在比赛结束之后有一个收费的题目直播讲解,价格是19.9元,报名链接是:

https://hihocoder.com/courses/10

14:30即可加入直播房间,我们会留给大家一段休息时间,大约在14:45开始正式讲解。

4 answer(s)

0

include

include

include

include

include

using namespace std;

define maxn 100010

define INF 0x3f3f3f3f

int par[maxn];

void init(int n) { for(int i = 1;i <= n;i++) par[i] = i; }

int find(int x) { return par[x] = par[x] == x ? x : find(par[x]); }

int a[maxn]; int s[maxn]; int n,k;

int main() { scanf("%d%d",&n,&k); init(n); for(int i = n;i >= 1;i--) scanf("%d",&a[i]); int ans; for(int i = 1;i <= n;i++) { int cnt = 0; s[a[i]] = 1; if(a[i] + 1 <= n && s[a[i]+1] > 0) { int j = find(a[i]+1); par[j] = a[i]; s[a[i]] = s[j]+s[a[i]]; if(s[a[i]] == k) cnt = 1; else cnt = 0; } if(a[i] - 1 >= 1 && s[a[i]+1] > 0) { int j = find(a[i]-1); par[j] = a[i]; s[a[i]] = s[j]+s[a[i]]; if(s[a[i]] == k) cnt = 1; else cnt =0;
} if(cnt == 1) ans = i; } printf("%d\n",n-ans); }

有那个大神帮忙看看 为什么按照ppt那种思路上做了还t了

0

棒棒棒!

0

今天直播的ppt没有嘛?

  • https://media.hihocoder.com/contests/offer26/offer26.pptx

  • 添加评论
  • reply
0

2题居然还可以0个插槽,一直被坑到比赛结束才发现……哭瞎

write answer 切换为英文 切换为中文


转发分享