Codeforces Round #478 (Div. 2)

AI Agent开发大全第一课-AI是什么以及如何使用AI 近年来,人工智能的迅猛发展引发了广泛的关注,尤其是“大模型”这一概念越来越深入人心。大模型,顾名思义,通常指的是那些拥有大量参数、能够处理复杂任务的机器学习模型。与传统小模型相比,大模型在数据处理、信息理解和生成等方面表现更加出色。为了理解为什么现在的AI被称为大模型,我们需要深入探讨几个关键因素。立角色是指在提示词中清晰地界定交互双方的身份。明确用户希望模型扮演的角色,可以帮助模型更准确地理解上下文和用户需求。 阅读详情

题目链接:http://codeforces.com/contest/975

 

A. Aramic script
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

In Aramic language words can only represent objects.

Words in Aramic have special properties:

  • A word is a root if it does not contain the same letter more than once.
  • A root and all its permutations represent the same object.
  • The root xx of a word yy is the word that contains all letters that appear in yy in a way that each letter appears once. For example, the root of "aaaa", "aa", "aaa" is "a", the root of "aabb", "bab", "baabb", "ab" is "ab".
  • Any word in Aramic represents the same object as its root.

You have an ancient script in Aramic. What is the number of different objects mentioned in the script?

Input

The first line contains one integer nn (1≤n≤1031≤n≤103) — the number of words in the script.

The second line contains nn words s1,s2,…,sns1,s2,…,sn — the script itself. The length of each string does not exceed 103103.

It is guaranteed that all characters of the strings are small latin letters.

Output

Output one integer — the number of different objects mentioned in the given ancient Aramic script.

Examples
Input
Copy
5
a aa aaa ab abb
Output
Copy
2
Input
Copy
3
amer arem mrea
Output
Copy
1
Note

In the first test, there are two objects mentioned. The roots that represent them are "a","ab".

In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer".

题意:给你n个字符串,然后把每个字符串中出现的字母取出来(构成的新字符串忽略顺序记为根),问这n个字符串中不同根的个数。

思路:用一个数组a记录每个字符串中出现的字母,然后再把它按照字典序构成一个新的字符串用set来维护,结果就是set所含的元素数。

代码实现如下:


  
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int n;
 5 int a[26];
 6 string s[1007], ss[1007];
 7 
 8 int main() {
 9     cin >>n;
10     for(int i = 0; i < n;i++) {
11         getchar();
12         cin >>s[i];
13         ss[i].clear();
14         memset(a, 0, sizeof(a));
15         int len = s[i].size();
16         for(int j = 0; j < len; j++) {
17             int t = s[i][j] - 'a';
18             a[t]++;
19         }
20         for(int j = 0; j < 26; j++) {
21             if(a[j]) ss[i] += (j + 'a');
22         }
23     }
24     set<string> m;
25     for(int i = 0; i < n; i++) {
26         if(!m.count(ss[i])) {
27             m.insert(ss[i]);
28         }
29     }
30     cout <<m.size() <<endl;
31     return 0;
32 }

  

 


 

 

B. Mancala
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.

Initially, each hole has aiai stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.

Note that the counter-clockwise order means if the player takes the stones from hole ii, he will put one stone in the (i+1)(i+1)-th hole, then in the (i+2)(i+2)-th, etc. If he puts a stone in the 1414-th hole, the next one will be put in the first hole.

After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.

Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.

Input

The only line contains 14 integers a1,a2,…,a14a1,a2,…,a14 (0≤ai≤1090≤ai≤109) — the number of stones in each hole.

It is guaranteed that for any ii (1≤i≤141≤i≤14) aiai is either zero or odd, and there is at least one stone in the board.

Output

Output one integer, the maximum possible score after one move.

Examples
Input
Copy
0 1 1 0 0 0 0 0 0 7 0 0 0 0
Output
Copy
4
Input
Copy
5 1 1 1 1 0 0 0 0 0 0 0 0 0
Output
Copy
8
Note

In the first test case the board after the move from the hole with 77 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 44.

题意:给你14个洞,每个洞里面有0个或奇数个石子,然后可以进行一次操作,这题操作就是将一个含非零石子数的洞中的石子全部取出然后按顺序填入后面的洞中(超出14就从第一个洞开始),每次只能放1个。

思路:因为总共就14个洞,所以就暴力即可(坑点:会爆int)~比赛时因为某个地方爆了int没发现和突然zz导致心态爆炸了……

 

 代码实现如下:


   
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 long long a[20], b[20];
 5 
 6 int main() {
 7     for(int i = 1; i <= 14; i++) {
 8         cin >> a[i];
 9     }
10     long long ans = 0, sum;
11     for(int i = 1; i <= 14; i++) {
12         sum = 0;
13         memset(b, 0, sizeof(b));
14         if(a[i] <= 0)
15             continue;
16         for(int j = 1; j <= 14; j++) {
17             if(i != j) {
18                 b[j] = a[j];
19             }
20         }
21         int n = a[i] / 14, m = a[i] % 14;
22         for(int j = 1; j <= 14; j++) b[j] += n;
23         for(int j = i + 1; j <= 14 && m > 0; j++, m--) {
24             b[j] ++;
25         }
26         for(int j = 1; m > 0; j++, m--) {
27             b[j] ++;
28         }
29         for(int j = 1; j <= 14; j++) {
30             if(b[j] % 2 == 0) {
31                 sum += b[j];
32             }
33         }
34         ans = max(ans, sum);
35     }
36     cout << ans << endl;
37     return 0;
38 }

   

 


  

 

C. Valhalla Siege
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.

Ivar has nn warriors, he places them on a straight line in front of the main gate, in a way that the ii -th warrior stands right after (i−1)(i−1) -th warrior. The first warrior leads the attack.

Each attacker can take up to aiai arrows before he falls to the ground, where aiai is the ii -th warrior's strength.

Lagertha orders her warriors to shoot kiki arrows during the ii -th minute, the arrows one by one hit the first still standing warrior. After all Ivar's warriors fall and all the currently flying arrows fly by, Thor smashes his hammer and all Ivar's warriors get their previous strengths back and stand up to fight again. In other words, if all warriors die in minute tt , they will all be standing to fight at the end of minute tt .

The battle will last for qq minutes, after each minute you should tell Ivar what is the number of his standing warriors.

Input

The first line contains two integers nn and qq (1≤n,q≤2000001≤n,q≤200000 ) — the number of warriors and the number of minutes in the battle.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109 ) that represent the warriors' strengths.

The third line contains qq integers k1,k2,…,kqk1,k2,…,kq (1≤ki≤10141≤ki≤1014 ), the ii -th of them represents Lagertha's order at the ii -th minute: kiki arrows will attack the warriors.

Output

Output qq lines, the ii -th of them is the number of standing warriors after the ii -th minute.

Examples
Input
Copy
5 5
1 2 1 2 1
3 10 1 1 1
Output
Copy
3
5
4
4
3
Input
Copy
4 4
1 2 3 4
9 1 10 6
Output
Copy
1
4
4
1
Note

In the first example:

  • after the 1-st minute, the 1-st and 2-nd warriors die.
  • after the 2-nd minute all warriors die (and all arrows left over are wasted), then they will be revived thus answer is 5 — all warriors are alive.
  • after the 3-rd minute, the 1-st warrior dies.
  • after the 4-th minute, the 2-nd warrior takes a hit and his strength decreases by 1.
  • after the 5-th minute, the 2-nd warrior dies.

题意:人肉盾请了解一下,第i个人可以抵挡ai只弓箭(看作hp),第i分钟地方射出ki只箭, 战争持续了q分钟。问每分钟还有多少人还活着(注意,当所有人都死亡时,将会集体复活,雾)。

思路:用前缀和记录前i个人的总hp,然后用t来记录前i分钟的弓箭数,当t>=sum[n]时将t设为0,然后进行二分即可。

代码实现如下:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 const int maxn = 2e5 + 7;
 5 int n, q;
 6 long long x;
 7 long long a[maxn], sum[maxn];
 8 
 9 int main() {
10     cin >>n >>q;
11     sum[0] = 0;
12     for(int i= 1; i<=n;i++) {
13         cin >>a[i];
14         sum[i] = sum[i-1] + a[i];
15     }
16     long long  t = 0;
17     while(q--) {
18         cin >>x;
19         t += x;
20         if(t >= sum[n]) t = 0;
21         int pos = upper_bound(sum,sum + n + 1, t) - sum - 1;
22         //cout <<pos <<endl <<endl;
23         cout <<n - pos <<endl;
24     }
25     return 0;
26 }
D. Ghosts
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.

There are nn ghosts in the universe, they move in the OXYOXY plane, each one of them has its own velocity that does not change in time: →V=Vx→i+Vy→jV→=Vxi→+Vyj→ where VxVx is its speed on the xx-axis and VyVy is on the yy-axis.

A ghost ii has experience value EXiEXi, which represent how many ghosts tried to scare him in his past. Two ghosts scare each other if they were in the same cartesian point at a moment of time.

As the ghosts move with constant speed, after some moment of time there will be no further scaring (what a relief!) and the experience of ghost kind GX=∑ni=1EXiGX=∑i=1nEXi will never increase.

Tameem is a red giant, he took a picture of the cartesian plane at a certain moment of time TT, and magically all the ghosts were aligned on a line of the form y=a⋅x+by=a⋅x+b. You have to compute what will be the experience index of the ghost kind GXGX in the indefinite future, this is your task for today.

Note that when Tameem took the picture, GXGX may already be greater than 00, because many ghosts may have scared one another at any moment between [−∞,T][−∞,T].

Input

The first line contains three integers nn, aa and bb (1≤n≤2000001≤n≤200000, 1≤|a|≤1091≤|a|≤109, 0≤|b|≤1090≤|b|≤109) — the number of ghosts in the universe and the parameters of the straight line.

Each of the next nn lines contains three integers xixi, VxiVxi, VyiVyi (−109≤xi≤109−109≤xi≤109, −109≤Vxi,Vyi≤109−109≤Vxi,Vyi≤109), where xixi is the current xx-coordinate of the ii-th ghost (and yi=a⋅xi+byi=a⋅xi+b).

It is guaranteed that no two ghosts share the same initial position, in other words, it is guaranteed that for all (i,j)(i,j) xi≠xjxi≠xj for i≠ji≠j.

Output

Output one line: experience index of the ghost kind GXGX in the indefinite future.

Examples
Input
Copy
4 1 1
1 -1 -1
2 1 1
3 1 1
4 -1 -1
Output
Copy
8
Input
Copy
3 1 0
-1 1 0
0 0 -1
1 -1 -2
Output
Copy
6
Input
Copy
3 1 0
0 0 0
1 0 0
2 0 0
Output
Copy
0
Note

There are four collisions (1,2,T−0.5)(1,2,T−0.5), (1,3,T−1)(1,3,T−1), (2,4,T+1)(2,4,T+1), (3,4,T+0.5)(3,4,T+0.5), where (u,v,t)(u,v,t) means a collision happened between ghosts uu and vv at moment tt. At each collision, each ghost gained one experience point, this means that GX=4⋅2=8GX=4⋅2=8.

In the second test, all points will collide when t=T+1t=T+1.

The red arrow represents the 1-st ghost velocity, orange represents the 2-nd ghost velocity, and blue represents the 3-rd ghost velocity.

题意:n只鬼当在同一时刻同一坐标遇见时会被对方吓到,问在时间为负无穷到正无穷范围(一开始没读清楚,到比赛结束第二题晚上才读清楚,可能是因为比赛结束后补D已经到一点头脑不清醒的缘故吧)内所有鬼被吓到次数的和。神奇的是,在T时刻,所有的鬼都在直线y=ax+b上,给你鬼在T时刻的横坐标和鬼的在xy轴的速度。

思路:本题求的其实就是鬼的行进路线所在直线间的交点数*2,易知两条直线在同一平面内只有平行和相交,由题意所说的T时刻所有的鬼在同一直线上知,鬼的行进路线如果平行只能是同时沿着T时刻的那条直线运动;而不平行的肯定会相交啦~我们先将题目中给的信息进行化简,如下图(字丑见谅):

因此我们只要统计每个a*vx - vy(p)出现的次数即可,而对于在同一个a*vx-y的鬼(数量记为q,借助map进行储存,这个我是看了别人的代码才知道的==!),由于T时刻的x不同,因此,他们是不会相遇的。最后我们只要把每个鬼对应的p和q相减的值加起来即可。
代码实现如下:
 
 1 #include <map>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 using namespace std;
 5 
 6 const int maxn = 2e5 + 7;
 7 typedef long long ll;
 8 int n, a, b;
 9 ll x[maxn], y[maxn];
10 map<ll,ll> mp1;
11 map<pair<ll, ll>, ll> mp2;
12 
13 int main() {
14     scanf("%d%d%d", &n, &a, &b);
15     for(int i = 0; i < n; i++) {
16         scanf("%*s%I64d%I64d", &x[i], &y[i]);
17         mp1[a * x[i] - y[i]]++;
18         mp2[make_pair(x[i], y[i])]++;
19     }
20     ll ans = 0;
21     for(int i = 0; i < n; i++) {
22         ans += mp1[a * x[i] - y[i]] - mp2[make_pair(x[i], y[i])];
23     }
24     printf("%I64d\n", ans);
25     return 0;
26 }

 

RK3588高速接口实战-PCIE 摘要: RK3588的PCIe接口支持PCIe 3.0x4和PCIe 2.1x1/x2,具备Root Complex和Endpoint模式,适用于NVMe SSD、5G模块等高速设备。硬件设计需注意85Ω/100Ω阻抗匹配、220nF AC耦合电容及100MHz参考时钟。设备树需配置控制器节点、PHY模式和IOMMU映射(RC模式用iommu-map,EP模式用iommus)。调试时可通过lspci检查链路状态,dmesg查看训练日志,perf分析性能。常见问题包括设备识别失败(检查复位时序、PHY配置)、 阅读详情

相关推荐

fastbin attack快速入门

0x01 fastbin简介 Fastbin包含0x20~0x80大小bin的数组指针,用于快速分配小堆块。fastbin按照单链表结构进行组织,相同大小的bin在同一个链表中,fd指向下一个bin,采用LIFO(Last In First Out)机制。在fastbin中,堆块的inuse标志都为1,处于占用状态,防止chunk释放时进行合并,加快小堆块的分配。 正常fastbin的使用 通过这个简单的案例来了解fastbin的单链表结构,malloc和free的过程。 #include<stdio

abelxu 1573

Mancala(模拟)

MancalaMancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which ...

codeswarrior的博客 1176

【PyTorch版本兼容性指南】如何在不同版本中正确使用torch.nn.attention

本文详细解析了PyTorch版本兼容性问题,特别是torch.nn.attention模块在不同版本中的使用差异。针对常见的ModuleNotFoundError错误,提供了三种实用解决方案:升级PyTorch版本、使用自定义实现和源码移植方案,并分享了最佳实践建议,帮助开发者有效避免兼容性问题。

weixin_29084231的博客 478

CodeForces - 975B:Mancala(暴力)

链接:https://vjudge.net/problem/CodeForces-975B 题目 Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has ai stones. When a player makes a move, he chooses a hole which contains a positive nu

Mr.RainsdRop的胡思乱想 614

IC版图设计之OASIS文件格式详解

OASIS(Open Artwork System Interchange Standard)是继GDSII之后新一代的集成电路版图数据交换标准,由SEMI在2004年正式发布(SEMI标准号:SEMI P39)。高压缩率:相比GDSII可减少3-10倍文件体积扩展性强:支持纳米级工艺的复杂图形描述跨平台兼容:独立于EDA工具和操作系统安全增强:内置校验和与加密支持。

ZZcppc的博客 2461

Comsol 压电换能器声场仿真(远场分析、边界元法优化)

本文详细介绍了在Comsol中使用边界元法进行压电换能器远场声场仿真的高效方法。针对传统有限元法计算远场时内存消耗大、耗时长的问题,文章阐述了边界元法在处理无限域、提升计算效率和精确获取远场指向性方面的核心优势,并提供了从多物理场耦合设置、网格划分策略到求解器配置及结果验证的完整实战指南。

weixin_29045585的博客 415

Codeforces Round #478 (Div. 2)B. Mancala(模拟)

Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has aiai stones. When a player makes a move, he chooses a hole which contains a ...

不二君 306

STM32H750实战:用TIM+DMA驱动ADC/DAC实现音频回环(附CubeMX配置避坑指南)

本文详细介绍了在STM32H750上构建高保真、低延迟音频链路的实战方法。通过配置TIM定时器作为硬件节拍器,精准触发ADC采集与DAC播放,并利用DMA实现数据的自动搬运,全程无需CPU干预。文章重点剖析了CubeMX配置中的关键步骤与常见“坑点”,如ADC的Conversion Data Management模式选择、DMA的FIFO与Burst模式配置,以及STM32H7系列必须开启ADC全局中断等,并提供了完整的代码实现与调试验证指南。

1066

Codeforces Round #478 (Div. 2) B. Mancala

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mancala is a game famous in the Middle East. It is played on a board that consists ...

gtuif的博客 241

L298N电机驱动模块的接线使用与代码实现

#include "iostm8s208mb.h" #define u8 uint8_t #define u16 uint16_t #define u32 uint32_t typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; // 关于LED灯的宏定义 #define LED2 PI_ODR_ODR2 //输出量 #define LE

Clichong 13万+

KNX实战—ETS5_智能开关从零到一的配置全流程

本文详细介绍了使用ETS5软件配置KNX智能开关的完整流程。从创建项目、构建建筑结构,到导入产品数据库、添加并配置开关模块与智能面板,再到设置延时开关、闪烁报警等进阶功能,并深入解析了群组地址的配置与链接方法。最后指导完成项目校验与程序下载,帮助用户实现从零到一的智能灯光基础控制功能配置。

joy55的博客 550

codeforce-------------Mancala

Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has aiai stones. When a player makes a move, he chooses a hole which contains a pos...

qq_45772483的博客 238

【用unity实现100个游戏之7】实现一个类《杀戮尖塔》的卡牌回合制游戏(附项目源码)

【用unity实现100个游戏之7】实现一个类《杀戮尖塔》的卡牌回合制游戏(附项目源码)

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1万+

Codeforces Round #478 (Div. 2) D. Ghosts

Codeforces Round #478 (Div. 2)D. Ghosts 点击打开链接题意:有n个鬼魂在二位坐标上直线行走,某个时间点,它们恰好在一条直线上,给你这条直线y=ax+b中的a和b,然后给你n个点的横坐标和它们在X轴和Y轴的速度,问从t=−∞  到t=+∞的时间段里,它们相互之间碰撞了几次。思路:列方程组:两个人i,j相撞的条件是:  a*x(i)+b+t*vy(i)=a*xj+...

qq_36782366的博客 168

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Codeforces Round #478 (Div. 2) ABC

比赛链接 A题 解题思路: 给予 n 个字符串,让求有多少个不同的词根(set存储)。 首先我们将每个都set去重,然后使用map数组存储当前词根,然后最后进行统计。 代码: #include <map> #include <cmath> #include <cstdio> #include <cstring> #incl...

LiangNiuMu的博客 180

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces Round #478 (Div. 2) D题

   题目链接:点击打开链接    因为两个ghost的相对速度方向和直接平行的时候才可能相遇,推公式得到a*vx-vy相等,并且他们相对速度不为0的ghost才能相遇,因此用map维护相对速度为0的 节点的对数和a*vx-vy的对数就可以得到答案。    #include&lt;bits/stdc++.h&gt; using namespace std; #define rep(i,j,k) f...

超越自我就是成功 251

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Codeforces Round #478 (Div. 2) D. Ghosts

D. Ghosts题目链接题意:挺有意思的一道题,说的是有n个鬼魂在二位坐标上直线行走,某个时间点,它们恰好在一条直线上,给你这条直线y=ax+b中的a和b,然后给你n个点的横坐标和它们在X轴和Y轴的速度,问从t=−∞到t=+∞的时间段里,它们相互之间碰撞了几次。思路:设任意两点i,j,它们在时间Tx的时候在横坐标上相遇,写出等式为,即设它们在时间Ty的时候相遇,同理可得。要想它们真正的相遇,需要...

brandong 806

Codeforces Round #478 (Div. 2) C. Valhalla Siege

C. Valhalla SiegeIvar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.Ivar has nn warriors, ...

s540239976的博客 337

Codeforces Round #478 (Div. 2) E. Hag's Khashba

E. Hag's Khashba time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Hag is a very talented person. He has always ...

ba82586628365094的博客 162
上一篇: Educational Codeforces Round 43 (Rated for Div. 2)
下一篇: CRB and Candies(组合数学+求逆元+lcm)
Dillonh
博客等级 码龄9年 34粉丝 66原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值