【解题总结】NWERC 2019(Codeforces Gym 102500)

我解决的:E(1 WA)、F、I、A。

没看的:H。

旁观的:C、G、D。

看了但没做出来的:K、B、J。

E Expeditious Cubing

简单题,略。

C Canvas Line

看起来是一个不很难的贪心,略。

F Firetrucks Are Red

题意:有 n n n 个点,每个点有一个数集。两个点的数集有非空交集则两个点可以以该数为权,连一条边。求一个生成树。

枚举数,将具有相同数的点连起来即可,要用并查集维护连通性。

#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> mp;
int tot, lst[200005];
int to[200005], nxt[200005], at[200005] = {
   0}, cnt = 0;
int ans[200005][3];
int fa[200005], siz[200005];
int Find(int x){
   
    return (x == fa[x] ? x: (fa[x] = Find(fa[x])));
}
int Union(int u, int v){
   
    u = Find(u), v = Find(v);
    if (u == v) return 0;
    if (siz[u] > siz[v]) fa[v] = u, siz[u] += siz[v];
    else fa[u] = v, siz[v] += siz[u];
    return 1;
}
int main(){
   
    int n;
    scanf("%d", &n);
    tot = 0;
    for (int i = 1; i <= n; ++i){
   
        int t, num;
        scanf("%d", &t);
        for (int j = 1; j <= t; ++j){
   
            scanf("%d", &num);
            if (!mp.count(num)) {
   
                mp[num] = ++tot;
                lst[tot] = num;
            }
            int id = mp[num];
            to[++cnt] = i, nxt[cnt] = at[id], at[id] = cnt;
        }
    }
    for (int i = 1; i <= n; ++i)
        fa[i] = i, siz[i] = 1;
    
    int res = 0;
    for (int i = 1; i <= tot; ++i){
   
        if (!at[i]) continue;
        int rep = to[at[i]];
        for (int j = at[i]; j; j = nxt[j]){
   
            if (Union(to[j], rep)){
   
                ans[++res][0] = to[j], 
                ans[res][1] = rep, 
                ans[res][2] = lst[i];
            }
        }
    }
    if (res < n - 1) {
   
        printf("impossible\n");
    }else {
   
        for (int i = 1; i <= res; ++i){
   
            printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
        }
    }
    return 0;
}

I Inverted Deck

题意:给定一个序列,问能否反转一个连续子序列使得序列不降。

先把相同的数缩成一个,使得序列中没有相邻的相同数。设序列为 a a a,从头开始,第一个不满足 a i ≤ a i + 1 a_i \le a_{i+1} ai

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您提供的链接是Codeforces的一个问题,问题编号为104377。Codeforces是一个知名的在线编程竞赛平台,经常举办各种编程比赛和训练。GymCodeforces的一个扩展包,用于组织私人比赛和训练。您提供的链接指向了一个问题的页面,但具体的问题内容和描述无法通过链接获取。如果您有具体的问题或需要了解关于Codeforces Gym的更多信息,请提供更详细的信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [http://codeforces.com/gym/100623/attachments E题](https://blog.csdn.net/weixin_30820077/article/details/99723867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [http://codeforces.com/gym/100623/attachments H题](https://blog.csdn.net/weixin_38166726/article/details/99723856)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [CodeforcesPP:Codeforces扩展包](https://download.csdn.net/download/weixin_42101164/18409501)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值