首页 > 其他分享 >AtCoder abc352

AtCoder abc352

时间:2024-05-04 23:00:39浏览次数:62  
标签:AtCoder given person vertices rank abc352 leq th

E

Problem Statement

You are given a weighted undirected graph $G$ with $N$ vertices, numbered $1$ to $N$. Initially, $G$ has no edges.

You will perform $M$ operations to add edges to $G$. The $i$-th operation $$(1 \leq i \leq M)$$ is as follows:

  • You are given a subset of vertices $S_i=\lbrace A_{i,1},A_{i,2},\dots,A_{i,K_i}\rbrace$ consisting of $K_i$ vertices. For every pair $u, v$ such that $u, v \in S_i$ and $u < v$, add an edge between vertices $u$ and $$v$$ with weight $$C_i$$.

After performing all $M$ operations, determine whether $G$ is connected. If it is, find the total weight of the edges in a minimum spanning tree of $G$.


赛时用并查集做连通图的判断,用优先队列维护每一个点的最小连接边(仅值),但想不出如何生成最小生成树,维护信息不足


F

Problem Statement

There are $N$ people, numbered $1$ to $N$.

A competition was held among these $N$ people, and they were ranked accordingly. The following information is given about their ranks:

  • Each person has a unique rank.
  • For each $1 \leq i \leq M$, if person $A_i$ is ranked $x$-th and person $B_i$ is ranked $y$-th, then $x - y = C_i$.

The given input guarantees that there is at least one possible ranking that does not contradict the given information.

Answer $N$ queries. The answer to the $i$-th query is an integer determined as follows:

  • If the rank of person $i$ can be uniquely determined, return that rank. Otherwise, return $-1$.

这应该是真的难题,赛时也才过了480个人,初步想法为带权并查集维护一条奇怪的链,带着缺口的链,然后几根链子来判断最后的答案

标签:AtCoder,given,person,vertices,rank,abc352,leq,th
From: https://www.cnblogs.com/9102qyy/p/18172927

相关文章

  • AtCoder Beginner Contest 351
    A-Thebottomoftheninth(abc351A)题目大意给定\(9\)个\(a_i\)和\(8\)个\(b_i\),问最后一个\(b_9\)是多少,使得\(\suma_i<\sumb_i\)。解题思路答案就是\(\suma_i-\sumb_i+1\)。神奇的代码a=sum(map(int,input().split()))b=sum(map(int,input().......
  • [atcoder]【LCR114] [
    importjava.util.*;classSolution{publicstaticvoidmain(String[]args){Solutionsolution=newSolution();Stringstr=solution.alienOrder(newString[]{"wrt","wrf","er","e......
  • [atcoder 351] [F Double Sum] [线段树]
    解法,使用线段树。请看代码:importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.math.BigInteger;importjava.util.StringTokenizer;publicclassMain{staticclassSegmentNode{intleft;......
  • Atcoder ABC 351 全题解
    乾岩我:G题来咯!!!大火:这G题,大家都不敢做,说是有人在里面放了毒瘤。我:做,做,为什么不做!不做也别想活着!!!(两天后)我:我的G题完成辣!!!!!!AB不讲C显然$2^a*2=2^{a+1}$。考虑用一个栈存球的大小是$2$的多少次方,每次插入球后,不断取出后面两个球,大小相同则合并,否则插入下一个......
  • AtCoder-abc350_g 题解
    原题链接题意简述有一个无向图,初始时没有边。接下来有一些操作:将\(u,v\)连边。询问\(u,v\)的距离是否为\(2\),如果是,则输出中间的那个点的编号,否则输出0。每次询问后,更新\(lastans\)为询问的答案,初始时为\(0\)。每次操作的\(opt,u,v\)使用\(lastans\)解码,......
  • AtCoder-abc350_f 题解
    原题链接题意简述给定一个字符串\(S\),对于每个匹配的括号,将括号内的字符左右翻转并大小写反转,然后删除括号。输出最后的序列。思路本题为文艺平衡树的模板题。扫一遍字符串进行括号匹配,每次把最内层的括号进行操作。最后遍历一遍平衡树,将不为括号字符的字符输出。FHQ_Treap......
  • AtCoder Beginner Contest 351
    B-SpottheDifference难度:⭐题目大意给定两个矩阵,找不同解题思路数据很小,暴力就行;神秘代码#include<bits/stdc++.h>#defineintunsignedlonglong#defineIOSios::sync_with_stdio(false);cin.tie(0);cout.tie(0);#defineendl'\n'usingnamespa......
  • AtCoder-abc351_f讲解
    原题翻译给定一个序列\(A\),求出:\[\sum\limits_{i=1}^N\sum\limits_{j=i+1}^N\max(A_j-A_i,0)\]答案小于\(2^{63}\)。思路这里提供三种思路(分块经XXR尝试,卡常卡不过):1权值树状数组将\(A\)离散化,设\(rk_i\)为\(A_i\)离散化后的排名,去重后元素个数为\(M\)。每......
  • AtCoder-abc351_d 题解
    原题翻译题意简述给定\(H\timesW\)的网格图,如果一个字符是#,则不能走到该字符上;如果是.,则可以走到该字符上,但如果它周围\(4\)个格子中有#字符,则不能再继续行走了。自由度是指从一个格子出发,能走到不同格子的数量(可以出发多次)。求出所有格子的最大自由度。思路考虑......
  • AtCoder Beginner Contest 208 E
    E-DigitProducts点击查看代码map<int,int>f[20];voidsolve(){intn,k;cin>>n>>k;autos=to_string(n);intm=s.size();function<int(int,int,int,int)>dfs=[&](inti,intlimit,intis_num,intmul)->int{if(i......