IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) 653C Bear and Up-Down(暴力)

RT-DETR模型应用过程中的报错处理及疑问解答,涉及环境搭建、模型训练、模块改进、论文写作 本文记录了RT-DETR模型的这一系列过程中可能发生的问题,以及大家非常关心的问题,这里统一做了一个记录和解答。 阅读详情

C. Bear and Up-Down
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two conditions are satisfied:

  • ti < ti + 1 for each odd i < n;
  • ti > ti + 1 for each even i < n.

For example, sequences (2, 8), (1, 5, 1) and (2, 5, 1, 100, 99, 120) are nice, while (1, 1), (1, 2, 3) and (2, 5, 3, 2) are not.

Bear Limak has a sequence of positive integers t1, t2, ..., tn. This sequence is not nice now and Limak wants to fix it by a single swap. He is going to choose two indices i < j and swap elements ti and tj in order to get a nice sequence. Count the number of ways to do so. Two ways are considered different if indices of elements chosen for a swap are different.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 150 000) — the length of the sequence.

The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 150 000) — the initial sequence. It's guaranteed that the given sequence is not nice.

Output

Print the number of ways to swap two elements exactly once in order to get a nice sequence.

Examples
input
5
2 8 4 7 7
output
2
input
4
200 150 100 50
output
1
input
10
3 2 1 4 1 4 1 4 1 4
output
8
input
9
1 2 3 4 5 6 7 8 9
output
0
Note

In the first sample, there are two ways to get a nice sequence with one swap:

  1. Swap t2 = 8 with t4 = 7.
  2. Swap t1 = 2 with t5 = 7.

In the second sample, there is only one way — Limak should swap t1 = 200 with t4 = 50.




题目链接:点击打开链接

给出n个数的序列, 对任意奇下标要小于后一个, 任意偶下标大于后一个, 可以交换一次, 问有多少种复合题意的方法.

暴力枚举, 记录不符合题意的位置, 暴力交换两个位置的数进行判断, 判断时只需判断交换位置的两个数以及不符合题意数的位置.

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
#include "cstdlib"
using namespace std;
typedef long long ll;
#define X first
#define Y second
#define exp 1e-8
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 15e4 + 5;
int n, a[MAXN], ans;
bool flag[MAXN];
std::vector<int> v;
bool Judge(int x)
{
	int val = a[x];
	if(x & 1) {
		if(x < n && val >= a[x + 1]) return false;
		if(x > 1 && val >= a[x - 1]) return false;
	}
	else {
		if(x < n && val <= a[x + 1]) return false;
		if(x > 1 && val <= a[x - 1]) return false;
	}
	return true;
}
int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i)
		if(!Judge(i)) {
			v.push_back(i);
			flag[i] = true;
		}
	if(v.size() > 10) {
		printf("0\n");
		return 0;
	}
	for(auto x : v) 
		for(int y = 1; y <= n; ++y)
			if(!flag[y] || y > x) {
				swap(a[x], a[y]);
				bool valid = Judge(x) && Judge(y);
				for(auto z : v) 
					if(!Judge(z)) valid = false;
				if(valid) ans++;
				swap(a[x], a[y]);
			}
	printf("%d\n", ans);
	return 0;
}


恒玄BES调试笔记-BES2500如何打开COMPEXP 打开Compressor and expander会占用资源,这个根据个人项目需求而定吧!打开方法,以及参数修改如下: config\best2300a_ibrt_anc\target.mk SPEECH_RX_COMPEXP ?= 1 apps\audioplayers\bt_sco_chain_cfg_default.c #if defined(SPEECH_RX_COMPEXP) /***************************************************** 阅读详情

相关推荐

NX二次开发入门必看:手把手教你搭建开发环境

想顺利开展nx二次开发,第一步就是配置好开发环境。本文详细讲解从安装准备到环境调试的完整流程,结合实际操作细节,帮你避开常见坑点,快速进入nx二次开发的实战阶段。

weixin_31569663的博客 1458

CF# IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C - Bear and Up-Down

诶呀,其实这是一道水题,水题,水题! 真的哩,大家想想暴力怎么做=。=,然后大家就应该都会了! 题意: 一个nice的数列 对于奇数位 必须满足ai#include<iostream> #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #include<stdlib.h> #include<

qq_24664053的博客 489

embedding计算过程

文章目录embedding计算过程(错了跟我讲,我会改)参考示例个人理解过程图示总结(基于pytorch) embedding计算过程(错了跟我讲,我会改) 参考示例 https://www.jianshu.com/p/63e7acc5e890 个人理解过程图示 总结(基于pytorch) 总的来说,就是将独热向量的长度(对应嵌入层的num_embeddings)转变为嵌入层的emdedding_size(而独热向量的维数就是你的数据中一共产生了多少个不一样的词,至少是这么多)。 数据的变化,将二维

纸上得来终觉浅,绝知此事要躬行! 1632

Codeforces 653C - Bear and Up-Down 暴力

C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The life goes up and down, just like nice sequ...

253

手把手教你用CCS v7.3调试TI DSP28377:从连接仿真器到看懂Flash里的秘密

本文详细介绍了使用CCS v7.3调试TI DSP28377的全过程,从连接仿真器到解析Flash启动机制。通过实战演示和关键配置要点,帮助工程师快速掌握DSP调试技巧,并深入探讨bootloader设计与在线升级的实现方法,提升开发效率。

weixin_29158413的博客 408

NLP实战:如何用CoNLL-2003数据集快速提升命名实体识别模型性能(附完整代码)

本文详细介绍了如何利用CoNLL-2003公开数据集,通过深度剖析数据特点、构建鲁棒的数据预处理流水线、选择合适的模型架构(如BERT-CRF)以及优化训练策略,来系统性地提升命名实体识别(NER)模型的性能。文章提供了完整的代码示例,并分享了处理数据不均衡、标签对齐等核心挑战的实战技巧,帮助读者从理论到实践全面掌握NER任务。

cola5的博客 494

Codeforces(653C)-C. Bear and Up-Down

原题链接 C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The life goes up and down, ju

L. 633

本地部署Llama 3中文版:Ollama量化配置与调优指南

大模型本地部署正在成为数据敏感场景下的主流选择。本地运行开源大模型,既能保护隐私又能降低调用成本,但中文能力往往成为瓶颈。以Llama 3为代表的开源模型,需借助中文微调与量化技术,才能在消费级显卡上流畅运行。量化通过压缩模型权重减小显存占用,配合Ollama等推理框架,可快速搭建私有中文AI服务。该方案适用于知识库问答、内容生成、离线助手等场景,并可通过OpenAI兼容接口无缝对接Dify等应用平台。本文从硬件选型、量化等级到Modelfile配置,系统梳理本地部署中文大模型的全链路实战方法与排错思路,帮

weixin_29035405的博客 82

IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C. Bear and Up-Down【模拟】

/* *********************************************** Author :Maltub Email :xiang578@foxmail.com Blog :htttp://www.xiang578.top ************************************************ */#

禅境花园 583

YOLOv11与Roboflow数据预处理实战:从原始数据到高性能模型

摘要 Roboflow平台与YOLOv11的结合为计算机视觉开发者提供了高效的工作流。Roboflow提供数据集管理、预处理、增强和导出的一站式解决方案,支持多种标注格式并与YOLOv11无缝集成。YOLOv11在YOLO系列基础上进行了架构创新,包括深度宽度优化、C3k2机制和C2PSA注意力机制,提供从纳米版到超大版的多种模型变体。 使用Roboflow的流程包括:注册工作区、收集/导入数据(支持本地和公开数据集)、专业标注(含SAM辅助)、预处理(尺寸调整、归一化等)和数据增强(几何变换和颜色调整)。

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 350

指纹浏览器降维打击(下):Cloudflare Turnstile 与 hCaptcha 的底层交互逻辑

本文将深度拆解:Turnstile 与 hCaptcha 的 Iframe 沙箱通信机制,动态混淆 JS 与 PoW(工作量证明)的物理破解法则,以及如何通过 C++ 底层事件合成与环境基因强绑定,实现验证码的“无感过验”。

数据知道的博客 422

Codeforces 653C Bear and Up-Down【暴力】

题目链接: http://codeforces.com/problemset/problem/653/C 题意: 给定序列,偶数位的数字比两边都大,则成为nice,只可以交换两个数字,问有多少种交换方式使得最后的序列为nice。 分析: 比赛的时候找规律,找呀找了好久都没看出来。。。。由于只可以交换一次,交换两个数字,所以最多改变的6个数字的关系。那...

An55511的博客 244

【RT-DETR涨点改进】独家注意力改进篇 | 手把手教你在RT-DETR上使用LSKAttention大核注意力机制(助力目标检测极限涨点)含多种创新改进点

本文提出了一种LSKA大核注意力机制优化RT-DETR模型的方法。LSKA通过将2D深度卷积核分解为级联的1D水平和垂直核,显著降低了计算复杂度和内存占用,尤其在处理大卷积核时优势明显。该模块在图像分类、目标检测等视觉任务中保持与LKA相当的性能,同时展现出更强的鲁棒性。文章详细介绍了LSKA的网络结构、核心代码实现方法,并提供了多种RT-DETR改进方案,包括rtdetr-r18-LSKA、rtdetr-l-LSKA等7种yaml配置文件,通过实验验证了该方法的有效性。

Ai缝合怪、助力小伙伴高效发论文 252

IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)-C - Bear and Up-Down-暴力枚举

http://codeforces.com/contest/653/problem/C 题意: 给n,给n个数。 要求一个合法序列满足: 偶数项>奇数项,奇数项 给一个序列,要求交换仅一对数,使得原序列变成合法序列 问你有多少种方案 扫一遍 看有多少个位置不符合要求,也就是  偶数项《奇数项,奇数项》偶数项的,我们把后一项坐标记录起来。 如果这样的坐标如果超过

缺氧 640

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C. Bear and Up-Down 暴力

C. Bear and Up-Down 题目连接: http://www.codeforces.com/contest/653/problem/C Description The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two ...

weixin_34348174的博客 195

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Codeforces 653C Bear and Up-Down【暴力+思维】题目还不错~

C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The life goes up and down, just like nice sequenc

mengxiang000000 729

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Codeforces Round #321 (Div. 2) 580C Kefa and Park(dfs)

题目链接: 第一行给你n、m,接下来的一行有n个数,如果为1则代表这个点有cat,接下来的n-1行每行给出x、y,表示x、y相连。问你从1出发 能到达的叶子结点有几个,要求到达叶子结点的路上连续有cat的点不超过m。 a数组保存结点是否含有cat,从1这个点开始dfs,每次dfs对cat数组操作,记录连续的含有cat的点数,回溯时再判断当前结点是否满足 条件,要求结点为叶子

GKHack's Blog 2041

Codeforces Round #200 (Div. 2)344E Read Time(二分)

E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike does not use slow hard disks

GKHack's Blog 1749

Codeforces Round #325 (Div. 2) 586ABC题解

题目链接:点击打开链接 A: 给出Alena的课表, 1代表有课, 0代表没课, 2个连续0以上可以回家休息, 问你一天在学校待多久. 直接模拟即可, 可以直接计算1, 101的数目. 我记录了开头的1和结尾的1, 然后减去2个连续0以上的个数就是答案. AC代码: #include "iostream" #include "cstdio" #include "cstring" #

GKHack's Blog 1711

Codeforces Round #308 (Div. 2)题解

第二天补的 并不都是自己写的 参考了别人的题解 感觉这次cf题意好懂 就是做起来嘛。。 毕竟我还太弱。。 只为落实 A. Vanya and Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input

GKHack's Blog 1674

Codeforces Round #322 (Div. 2) 581A 581B 581C

581A链接:点击打开链接 给你a只红袜子,b只蓝袜子,问你可以组成多少对颜色不同的袜子以及剩下多少对单色袜子。 小小的脑洞,答案分别为a, b最小值以及a - b绝对值的一半。 AC代码: #include "iostream" #include "cstdio" #include "cstring" #include "algorithm" using na

GKHack's Blog 1665

Codeforces Round #250 (Div. 2) 437C The Child and Toy(脑洞贪心)

C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On Children's Day, the child got a toy

GKHack's Blog 1627

Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

GKHack's Blog 1617

Codeforces Round #315 (Div. 2)569C Primes or Palindromes?(预处理)

C. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that t

GKHack's Blog 1599

Codeforces Round #201 (Div. 2) 347C Alice and Bob(脑洞)

C. Alice and Bob time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It is so boring in the summer holiday, isn

GKHack's Blog 1584

Manthan, Codefest 16 633C Spy Syndrome 2(dfs + stl)

C. Spy Syndrome 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After observing the results of Spy Syndro

GKHack's Blog 1574
上一篇: Codeforces Round #344 (Div. 2) 631C Report(脑洞+stl)
下一篇: IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) 653B Bear and Compressing(dfs + stl)
GKHack
博客等级 码龄11年 48粉丝 291原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值