首页 > 其他分享 >“蔚来杯“2022牛客暑期多校训练营3,签到题CAJHF

“蔚来杯“2022牛客暑期多校训练营3,签到题CAJHF

时间:2023-04-27 22:33:31浏览次数:37  
标签:10 le NIO 签到 蔚来 多校 number int maxn


题号 标题 已通过代码 通过率 团队的状态
A Ancestor 点击查看 1383/3940
B Boss 点击查看 54/734
C Concatenation 点击查看 2603/9404
D Directed 点击查看 62/157
E Electrician 点击查看 18/38
F Fief 点击查看 378/2528
G Geometry 点击查看 73/1076
H Hacker 点击查看 468/3315
I Ice Drinking 点击查看 28/212
J Journey 点击查看 1236/7800

文章目录

  • C.Concatenation
  • A.Ancestor
  • J.Journey
  • H.Hacker
  • F.Fief

C.Concatenation

题目描述
NIO was the king of the OIN Kingdom.

He had NN children and wanted to teach them how to count. In the OIN Kingdom, pental is used in counting, so his children can only use 0, 1, 2, 3, and 4 to represent a number.

One day, NIO asked his children to write down their favorite numbers. After that, he came out with a problem: if he concatenated these numbers into a big number, what is the smallest number he could get? However, this problem was too hard for him to solve, so can you help him?
输入描述:
The first line contains an integer N(1 \le N \le 2*10^6)N(1≤N≤2∗10
6
), denoting the number of NIO’s children.

Then follows NN lines, each line contains a string s_is
i

denotes the favorite number of the iith child. The string is composed of 0, 1, 2, 3, and 4, but may have leading zeros because NIO’s children hadn’t fully understood how to count.

\sum_{i=1}^{N} |s_i|\le 2*10^7∑
i=1
N

∣s
i

∣≤2∗10
7

输出描述:
One integer denotes the smallest number NIO can get.
示例1
输入
复制
5
121
1
12
00
101
输出
复制
00101112112
备注:
If you have designed an algorithm whose time complexity is O(|S|\log|S|)O(∣S∣log∣S∣) or so, please think twice before submitting it. Any algorithm other than linear complexity is NOT supposed to pass this problem. But of course, you can have a try. If you do so, we wish you good luck.

题意:

  • 给定n个字符串,求一个将他们拼接起来的方案,使得结果的字典序最小。

思路:

  • 一个简单的做法是,对n个字符串排序,a在b前面的条件是a+b<b+a
  • 使用stable_sort可以保证复杂度为O(|S|log n)。
  • 为了优化速度,还可以给cmp函数加上&,const,和inline。
  • 可以换int为LL,然后把变量开到外面去。
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
typedef long long LL;
const LL maxn = 4e6+10;
string a[maxn];
inline bool cmp(const string &x,const string &y){
    return x+y<y+x;
}
int main(){
    IOS;
    LL n;  cin>>n;
    for(LL i = 1; i <= n; i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    for(LL i = 1; i <= n; i++){
        cout<<a[i];
    }
    return 0;
}

A.Ancestor


题目描述
NIO is playing a game about trees.

The game has two trees A, BA,B each with NN vertices. The vertices in each tree are numbered from 11 to NN and the ii-th vertex has the weight v_iv
i

. The root of each tree is vertex 1. Given KK key numbers x_1,\dots,x_kx
1

,…,x
k

, find the number of solutions that remove exactly one number so that the weight of the lowest common ancestor of the vertices in A with the remaining key numbers is greater than the weight of the lowest common ancestor of the vertices in B with the remaining key numbers.
输入描述:
The first line has two positive integers N,K (2 \leq K \leq N \leq 10^5)N,K(2≤K≤N≤10
5
).

The second line has KK unique positive integers x_1,\dots,x_K (x_i \leq N)x
1

,…,x
K

(x
i

≤N).

The third line has NN positive integers a_i (a_i \leq 10^9)a
i

(a
i

≤10
9
) represents the weight of vertices in A.

The fourth line has N - 1N−1 positive integers {pa_i}{pa
i

}, indicating that the number of the father of vertices i+1i+1 in tree A is pa_ipa
i

.

The fifth line has nn positive integers b_i (b_i \leq 10^9)b
i

(b
i

≤10
9
) represents the weight of vertices in B.

The sixth line has N - 1N−1 positive integers {pb_i}{pb
i

}, indicating that the number of the father of vertices i+1i+1 in tree B is pb_ipb
i

.
输出描述:
One integer indicating the answer.
示例1
输入
复制
5 3
5 4 3
6 6 3 4 6
1 2 2 4
7 4 5 7 7
1 1 3 2
输出
复制
1
说明
In first case, the key numbers are 5,4,3.
Remove key number 5, the lowest common ancestors of the vertices in A with the remaining key numbers is 2, in B is 3.
Remove key number 4, the lowest common ancestors of the vertices in A with the remaining key numbers is 2, in B is 1.
Remove key number 3, the lowest common ancestors of the vertices in A with the remaining key numbers is 4, in B is 1.
Only remove key number 5 satisfies the requirement.
示例2
输入
复制
10 3
10 9 8
8 9 9 2 7 9 0 0 7 4
1 1 2 4 3 4 2 4 7
7 7 2 3 4 5 6 1 5 3
1 1 3 1 2 4 7 3 5
输出
复制
2
备注:
The lowest common ancestor (LCA) (also called least common ancestor) of two nodes v and w in a tree or directed acyclic graph (DAG) T is the lowest (i.e. deepest) node that has both v and w as descendants, where we define each node to be a descendant of itself (so if v has a direct connection from w, w is the lowest common ancestor).(From Wiki.)

题意:

  • 给出两棵编号1-n的树A B,A B树上每个节点均有一个权值,给出k个关键点的编号

    标签:10,le,NIO,签到,蔚来,多校,number,int,maxn
    From: https://blog.51cto.com/gwj1314/6232259

相关文章

  • 2022“杭电杯”中国大学生算法设计超级联赛(3)签到题4题
    ProblemsSolvedProblemIDTitleRatio(Accepted/Submitted)1001EquipmentUpgrade33.53%(115/343)1002BossRush13.79%(246/1784)1003CyberLanguage69.82%(1189/1703)1004DividetheSweets3.24%(7/216)1005SpanningTreeGame9.83%(40/407)1006Du......
  • 2022“杭电杯”中国大学生算法设计超级联赛(1)签到题5题
    SolvedPro.IDTitleRatio(Accepted/Submitted)1001String11.88%(125/1052)1002Dragonslayer19.56%(473/2418)1003Backpack14.23%(270/1897)1004Ball15.29%(52/340)1005Grammar12.21%(21/172)1006Travelplan24.18%(22/91)1007Treasure12.93%(38/294)......
  • “蔚来杯“2022牛客暑期多校训练营2,签到题GJK
    题号标题已通过代码通过率团队的状态AFalfawithPolygon点击查看56/445Blight点击查看50/326CLinkwithNimGame点击查看192/1035DLinkwithGameGlitch点击查看831/6211EFalfawithSubstring点击查看264/3287FNIOwithStringGame点击查看52/......
  • “蔚来杯“2022牛客暑期多校训练营1,签到题GADI
    题号标题已通过代码通过率团队的状态AVillages:Landlines点击查看1673/4177通过BSpiritCircleObservation点击查看39/299未通过CGrabtheSeat!点击查看88/392未通过DMochaandRailgun点击查看1589/8517通过ELTCS点击查看43/324未通过FCut点击......
  • 多校第六场 1011 hdu 5363Key Set(组合数学)
    题目链接:hdu5363题目大意:给出一个到n的自然数集合,问它有多少个子集,元素之和是偶数。题目分析:首先偶数不会导致集合的和的奇偶性发生变化;奇数会导致集合的和的奇偶性发生变化。我们设奇数m1个,偶数m2个。所以我们可以选取0~m1个偶数,但是只能选取偶数个奇数。那么偶数的方案数就是......
  • xor (牛客多校) (线性基+ 线段树)
      思路:问xor起来有没有某个值,想到线性基然后发现问L-R区间的集合都要表示x,利用线性基的交集解决在利用线段树解决区间问题 #include<iostream>usingnamespacestd;typedefunsignedintui;constintmaxn=50005;structL_B{//线性基结构体ui......
  • sequence (牛客多校) (区间包含某个值的最大最小, 和那个东西)
     思路:一步一步的拆解分析有一个min(al...r)通过这个东西那么就可以根据这个ai值分区间,可以通过单调zhai处理当然也可以去利用启发式合并处理,  在处理区间的时候,因为这个有正负,要分类讨论正就是最大负数就是最小遇到区间包含某个值的区间最大最小那么就......
  • free (牛客多校) (dj最短路+dp优化处理)
    本题大意:给出n,m,s,t,k,n个点,m条路,求s到t的最短路,并且最多k条路免费,然后给出m行,u,v,w,代表u到v有一条权值为w的双向路。 思路:就是dj最短路+一个dp维度的处理,dp[i][j],到第i个节点用了多少个免费的路径的最短路径 ......
  • HDU 4864Task(多校联合训练1)(贪心)
    题目地址:HDU4864这题又是一上来认为是最小费用流,但是边太多,果然,敲完交上去后不断TLE。。小优化了两次也没过。。。sad。。后来看了题解才发现是贪心。。。贪心也不好想。大体思路是很好想的,就是先都按时间从大到小排序,再遍历任务,从机器里找能匹配的,并在能匹配的里边找等级尽量小的......
  • 最新版人脸识别小程序 图片识别 生成码签到码 地图上选点进行位置签到 计算签到距离
    技术选型1,前端小程序原生MINA框架cssJavaScriptWxml2,管理后台云开发Cms内容管理系统web网页3,数据后台小程序云开发云函数云开发数据库(基于MongoDB)云存储4,人脸识别算法基于百度智能云实现人脸识别一,用户端效果图预览老规矩我们先来看效果图,如果效果图符合你的需求,就继续往下......