Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)

IC版图设计布局经验90条! 13 如果一个cell调用其它cell,被调用的cell的vssx,vddx,vssb,vddb如果没有和外层cell连起来,要打上PIN,否则通不过diva检查.尽量在布局低层cell时就连起来。48 在匹配电路的mos管左右画上dummy,用poly,poly的尺寸与管子尺寸一样,dummy与相邻的第一个poly gate的间距等于poly gate之间的间距。8 更改cell时查看路径,一定要在正确的library下更改,以防copy过来的cell是在其他的library下,被改错。 阅读详情
B. Histogram Ugliness
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Little Dormi received a histogram with n bars of height a1,a2,…,an for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it to his liking.

To modify the histogram, Little Dormi is able to perform the following operation an arbitrary number of times:

Select an index i (1≤i≤n) where ai>0, and assign ai:=ai−1.
Little Dormi defines the ugliness score of his histogram (after performing some number of operations) as the sum of the vertical length of its outline and the number of operations he performed on it. And to make the histogram as perfect as possible, he would like to minimize the ugliness score after modifying it with some number of operations.

However, as his histogram is very large, Little Dormi is having trouble minimizing the ugliness score, so as Little Dormi's older brother, help him find the minimal ugliness.

Consider the following example where the histogram has 4 columns of heights 4,8,9,6:


The blue region represents the histogram, and the red lines represent the vertical portion of the outline. Currently, the vertical length of the outline is 4+4+1+3+6=18, so if Little Dormi does not modify the histogram at all, the ugliness would be 18.

However, Little Dormi can apply the operation once on column 2 and twice on column 3, resulting in a histogram with heights 4,7,7,6:


Now, as the total vertical length of the outline (red lines) is 4+3+1+6=14, the ugliness is 14+3=17 dollars. It can be proven that this is optimal.

Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). Description of the test cases follows.

The first line of each test case contains a single integer n (1≤n≤4⋅105).

The second line of each test case contains n integers a1,a2,…,an (0≤ai≤109).

It is guaranteed that the sum of n over all test cases does not exceed 4⋅105.

Output
For each test case output one integer, the minimal ugliness Little Dormi can achieve with the histogram in that test case.

Example
inputCopy
2
4
4 8 9 6
6
2 1 7 4 0 0
outputCopy
17
12
Note
Example 1 is the example described in the statement.

The initial histogram for example 2 is given below:


The ugliness is currently 2+1+6+3+4=16.

By applying the operation once on column 1, six times on column 3, and three times on column 4, we can end up with a histogram with heights 1,1,1,1,0,0:


The vertical length of the outline is now 1+1=2 and Little Dormi made 1+6+3=10 operations, so the final ugliness is 2+10=12, which can be proven to be optimal.


题解:贪心,注意每次贪左侧。

test 1
test 2

#include<bits/stdc++.h>
#define int long long

using namespace std;

inline int read()  {  
    int x=0,f=1;  
    char ch=getchar();  
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  
    return x*f;  
}

const int maxn=4e5+10;
int n,m,T;
int a[maxn];

void solve(){
    cin>>n;
    a[n+1]=0;
    int cnt=0,c=0;
    for(int i=1;i<=n;++i) cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;++i){
        int to=min(a[i],max(a[i-1],a[i+1]));
        ans+=a[i]-to+abs(to-a[i-1]);
        a[i]=to;
    }
    cout<<ans+a[n]<<endl;
}

signed main()
{
	cin>>T;
	while(T--) solve();
	//for(;;);
	return 0;
}
C. Little Alawn's Puzzle
time limit per test2.5 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
When he's not training for IOI, Little Alawn enjoys playing with puzzles of various types to stimulate his brain. Today, he's playing with a puzzle that consists of a 2×n grid where each row is a permutation of the numbers 1,2,3,…,n.

The goal of Little Alawn's puzzle is to make sure no numbers on the same column or row are the same (we'll call this state of the puzzle as solved), and to achieve this he is able to swap the numbers in any column. However, after solving the puzzle many times, Little Alawn got bored and began wondering about the number of possible solved configurations of the puzzle he could achieve from an initial solved configuration only by swapping numbers in a column.

Unfortunately, Little Alawn got stuck while trying to solve this harder problem, so he was wondering if you could help him with it. Find the answer modulo 109+7.

Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). Description of the test cases follows.

The first line of each test case contains a single integer n (2≤n≤4⋅105).

The next two lines of each test case describe the initial state of the puzzle grid. Each line will be a permutation of the numbers 1,2,3,…,n and the numbers in each column and row will be pairwise distinct.

It is guaranteed that the sum of n over all test cases does not exceed 4⋅105.

Output
For each test case output a single integer, the number of possible solved configurations of the puzzle Little Alawn can achieve from an initial solved configuration only by swapping numbers in a column. As the answer can be very large, please output it modulo 109+7.

The answer for each test case should be on a separate line.

Example
inputCopy
2
4
1 4 2 3
3 2 1 4
8
2 6 5 1 4 3 7 8
3 8 7 5 1 2 4 6
outputCopy
2
8
Note
The two possible puzzle configurations for example 1 are:

[1,4,2,3] in the first row and [3,2,1,4] in the second;
[3,2,1,4] in the first row and [1,4,2,3] in the second.

题解:并查集。考察思维。
#include<bits/stdc++.h>
#define int long long

using namespace std;

inline int read()  {  
    int x=0,f=1;  
    char ch=getchar();  
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  
    return x*f;  
}

const int maxn=4e5+10;
int T,n,a[maxn],b[maxn],p[2*maxn];
const int mod=1e9+7;

int finds(int x){
    if(x!=p[x]) p[x]=finds(p[x]);
    return p[x];
}

void uni(int a,int b){
    p[finds(a)]=finds(b);
}

void solve(){
    n=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<=n;++i) b[i]=read();
    for(int i=1;i<=n;++i) p[i]=i;
    for(int i=1;i<=n;++i) uni(a[i],b[i]);
    int ans=1;
    for(int i=1;i<=n;++i){
        if(p[i]==i) ans=(ans*2)%mod;
    }
    cout<<ans<<endl;
}

signed main()
{
	T=read();
	while(T--) solve();
	//for(;;);
	return 0;
}
【调优】OpenClaw从零开始高阶调优之skill篇 本文详细解析了OpenClaw技能系统的核心机制。首先介绍了技能的分层加载逻辑,按照优先级从高到低依次为:工作区专属技能、全局共享技能、出厂自带技能和自定义路径技能。通过流程图展示了从扫描到注册的完整加载流程,并解释了同名技能覆盖规则。随后深入剖析了SKILL.md文件结构,包含YAML元数据定义技能属性和Markdown正文说明使用方法,以公众号写作技能为例展示了具体配置。文章还提供了技能优先级切换的实用技巧,帮助用户灵活管理不同版本的技能。 阅读详情

相关推荐

图像相似度的评价指标 : FID(Fréchet Inception Distance)

FID(Fréchet Inception Distance) 是用来计算真实图像与生成图像的特征向量间距离的一种度量。如果FID值越小,则相似程度越高。最好情况即是FID=0,两个图像相同。 实际计算: 参考链接:https://machinelearningmastery.com/how-to-implement-the-frechet-inception-distance-fid-from-scratch/ # example of calculating the frechet inceptio

weixin_43723625的博客 1万+

CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes)(A-C)

A. Good Pairs 题意: 思路: 观察上面的数学等式,有没有发现只要绝对值开出来不变号,那么一定成立?所以取个最大和最小即可 #include<bits/stdc++.h> using namespace std; const int maxn=2e5+100; struct node{ int v,idx; }a[maxn]; bool cmp1(node a,node b) { return a.v<b.v; } int main() { int n

RIPKEY的博客 549

电力现货市场出清机制解析:从理论到实践(附节点电价计算实例)

本文深入解析电力现货市场的核心出清机制,重点阐述了节点边际电价的计算原理与实践方法。通过对比系统边际电价、节点边际电价和分区边际电价三种模式,揭示了市场出清价格如何反映电力供需与网络阻塞。文章结合IEEE 30节点系统,提供了基于MATLAB和最优潮流模型的计算实例,详细展示了从构建模型到求解对偶变量以获取节点电价的全过程,为理解电力市场定价机制提供了从理论到实践的完整路径。

whisky的博客 757

CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes)

PROMBLE D:K-good We say that a positive integernniskk-good for some positive integerkkifnncan be expressed as a sum ofkkpositive integers which givekkdistinct remainders when divided bykk. Given a positive integernn, find somek≥2k≥2so that...

m0_61949623的博客 255

GX WORKS2通过交换机连接PLC的方法

三菱PLC连接方法的分享

weixin_64927621的博客 3620

2024.6.10丨基于DIAMOND与VFDB数据库的致病菌毒力因子高效注释指南

本文详细介绍了基于DIAMOND与VFDB数据库的致病菌毒力因子高效注释方法,涵盖工具安装、参数优化、数据库选择及实战案例解析。通过DIAMOND的快速比对和VFDB的全面毒力因子数据,显著提升微生物基因组研究效率,适用于临床检测、食品安全监测等多个场景。

weixin_33712987的博客 376

【CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes】

CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes!) 第一题都没过, 分好低儿, emo~~~ 不过也发现了一点点找规律的技巧 A. Good Pairs #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1e5 + 10; int n; typedef pair<in

m0_63216173的博客 832

【免费】最新区块链钱包和私钥的助记词碰撞器,使用python开发

最新钱包私钥助记词碰撞器,搏一搏单车变摩托!

weixin_48529185的博客 1万+

CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes) A-B

C之后的尚未看题解 A: A. Good Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an arraya1,a2,…,ana1,a2,…,anof positive integers. Agood pairis a pair of indices(i,j)(i,j)...

m0_61949623的博客 337

WEB浏览器视频流播放方案

基于Media Source Extensions播放视频流 浏览器播放视频的几种方法 一、H5 video标签 在浏览器播放视频,可以使用HTML5原生的video标签。但其播放的格式使用一定限制的,目前video只支持三种格式WebM、Ogg、MP4。 WebM:WebM 文件使用 VP8 视频编解码器和 Vorbis 音频编解码器 Ogg :Ogg 文件使用 Theora 视频编解码器和 Vorbis音频编解码器 MP4: MPEG 4文件使用 H264 视频编解码器和AAC音频编解码器 上面三种

machh的专栏 2381

从“能跑”到“好用”:一名 Python 开发者的工程化进阶之路【Python心得篇】

Python 早已不只是写脚本、跑数据的工具。后端服务AI Agent 编排层自动化平台核心语言数据与业务之间的“中枢层”区别只在于:你是用脚本方式,还是工程方式在写。如果你已经能写“能跑的 Python”,下一步,就是让它长期可跑、稳定可演进。Python 的真正价值不在于“写得快”,而在于能否支撑持续演进的工程实践。当代码从一次性脚本走向长期运行的系统,开发者必须从结构设计、职责拆分、性能意识和类型约束等方面进行系统性思考。

博客 1546

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) E

E.Lost Array (思维 bfs) 题目链接 题目大意 交互题。给定n(1≤n≤500)n(1\leq n \leq 500)n(1≤n≤500)个元素一个数组,你每一次询问可以获得其中k(1≤k≤n)k(1\leq k \leq n)k(1≤k≤n)个数的异或值,要求询问次数不超过500500500次计算出nnn个数的异或值。 题解 首先考虑异或的两个经典性质 xxx^x=0x=0x=0 xxx^0=x0=x0=x 因此,对于一个数来说,异或奇数次的值都是相同用的,偶数次同理。 我们考虑将每一次

m0_46527476的博客 339

Qualcomm 常用NV列表

^ NV ITEM ^ 功能^^ |NV10 |mode prefer,找网模式|新平台使用NV80000| ^NV74 NV74=0关闭自动接听电话^ |NV240 |NV240=FALSE|EVDO出现网络的问题,此项必须设定为FALSE| |NV255 |CDMA规避网络列表(SID/NID号)| |NV256 |

sdrgtywretyeruet的专栏 5770

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)ABC题解

第一次Div. 2破三留念,F1有思路但是Wa4,如果之后懂了会补 交互就算了吧 A. Colour the Flag 题意: 给一个由 “W”、“R”、"." 构成的n×m的二维网格,其中".“可以替换为"W"或"R”。问将所有的"."都替换掉之后,该图能否表示为由 “W”、"R"交替形成的图。: 思路: 对于一顶的nnn和mmm,符合条件的方格实际上只有两种,即第一个字母为“W”或“R”: 第一种 第二种 WRWRW RWRWR RWRWR WRWRW WRWRW RWRWR

m0_51499184的博客 333

假人有限元模型

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) AB题解

A. Colour the Flag 题目大意: 有一个n*m的字符数组,由‘R’,‘W’,或者‘.’组成,‘.’表示空白,‘R’表示红色,‘W’表示

qq_52109814的博客 198

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)题解

D. Lost Tree 有n个点的树,让你猜哪些是边 选择一个点r,可以得到其它点到r的最短距离 可以询问n/2次!!!向上取整!!! 那就是间隔一层询问一次 看以1为根结点时,奇数层的个数与偶数层个数的大小 int n,r,x,a[maxn]; int cnt1,cnt2; bool is[maxn][maxn]; void solve() { sd(n); printf("? 1\n");fflush(stdout); cnt2=-1; rep(i,1,n) { sd(a[i]);

XLH1129的博客 386

Camera2Demo

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

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) E. Lost Array(构造)

LINK 最后一定是把所有询问异或起来得到答案 设第iii个数询问了cic_ici​次显然cic_ici​为奇数且满足∑i=1nci=sum\sum\limits_{i=1}^nc_i=sumi=1∑n​ci​=sum 其中sumsumsum表示总的询问数字,那么共询问sumk\frac{sum}{k}ksum​次且满足max{ci}<=sumkmax \{c_i\}<=\frac{sum}{k}max{ci​}<=ksum​ 于是我们初始把所有ci=1c_i=1ci​=1,然后每次取出一

jziwjxjd的博客 529

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) D. Lost Tree

D. Lost Tree 题意 先给定一个树,你每次可以询问某个点到 nnn 个点的距离,要求通过最多 $\left \lceil \frac{n}{2} \right \rceil $ 次询问,得到树的结构。 题解 以 111 作为根节点,先询问根到其他点的距离,就得到了每个点的深度; 把所有 nnn 个点染两种颜色,也就是深度奇偶相同的点是同一种颜色; 如果距离为 111 那么两个点之间有一条边; 询问颜色数少的节点。 代码 #include<bits/stdc++.h> #define

bandiaoz的博客 225

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) E. Lost Array

E. Lost Array 题意 给你 nnn 个数,每次可以询问 k(1≤k≤n)k(1 \le k \le n)k(1≤k≤n) 个数的异或和,要求用最少的询问得到所有 nnn 个数的异或和。如果没有可能的方案,则输出 -1。 题解 异或奇数次等价异或一次,异或偶数次等价于没有异或; 这个问题等价于一个经典的问题,有 nnn 枚正面朝上的硬币,每次可以选择 kkk 个硬币翻转,怎么用最少的操作次数让所有硬币反面朝上; 枚举翻转中正面朝上的个数即可。 代码 #include <bits/stdc

bandiaoz的博客 205

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) B. Histogram Ugliness(贪心)

LINK Ⅰ.对于aia_iai​来说,若满足ai>ai−1&&ai>ai+1a_i>a_{i-1}\&\&a_i>a_{i+1}ai​>ai−1​&&ai​>ai+1​ 那么把aia_iai​减小到max(ai−1,ai+1)\rm max(a_{i-1},a_{i+1})max(ai−1​,ai+1​)不会使答案变得更差 因为花费一次操作机会代价加一,却能使代价减少222,收益和为−1-1−1 Ⅱ.若比两边都小,操作一次

jziwjxjd的博客 578

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) D. Lost Tree(交互,二分/图,思维)

LINK 题意 交互题,给定一个数字nnn表示树的节点数 你需要在不多于n+12\frac{n+1}{2}2n+1​次询问后得到树上的每一条边 每次询问你可以给出一个点xxx,然后会返回xxx到每个点的距离 第一次询问没有树上的任何信息,所以选任何一个点都是一样的,不妨选择点111 那么得到数组disidis_idisi​表示111到iii的最短路为disidis_idisi​ 现在怎么做?? 若过可以询问nnn次,那么对每个点询问一次得到相邻边即可 现在只能询问⌈x⌉2\frac{ \lceil x \

jziwjxjd的博客 442

CF1534B Histogram Ugliness-Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)

Problem - 1534B - Codeforces B. Histogram Ugliness time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Dormi received a histogram withnnbars of heighta1,a2,…,ana1,a2,…,anfor Chr...

jisuanji2606414的博客 229

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)题解A-D

A. Colour the Flag 略 #include <iostream> #include <algorithm> #include <string> using namespace std; char a[100][100]; int main() { int t; cin >> t; while(t--) { int n, m; cin >> n >> m; stri

Arctic_Clam的博客 383

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) 1534 E - Lost Array

1534E - Lost Array 题目大意: 交互题 给定一个长度为N的序列,每次询问K个不同下标的数的亦或和。 在不超过500次询问内求出整个序列的答案,如果不能直接输出-1。 思维: 无视下标,将整个序列分为两个部分,已知亦或和的部分和未知亦或和的部分。 询问k个数,可以从已知部分中选j个, 那么就要从未知部分中选k-j个,未知的会变成已知的,已知的会变成未知的。 题目所求即在最小次数内将未知部分全部变为已知序列。 解题: 求最短路利用bfs模拟,path记录路径。队列模拟转换。 #i

m0_52186223的博客 224
上一篇: Codeforces Round #724 (Div. 2)
下一篇: 交互题学习
haoduoyin1iugou
博客等级 码龄6年 56粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值