HDU 1698 Just a Hook

基于PyTorch与PyQt5的AI图片风格迁移桌面应用开发全流程解析 卷积神经网络(CNN)通过多层卷积操作提取图像特征,其中浅层网络捕捉边缘、纹理等基础信息,深层网络则理解物体的高级语义内容。基于这一原理,神经风格迁移技术得以实现,它通过分离并重组内容图像的结构与风格图像的纹理特征,创造出全新的艺术化图像。这项技术的核心价值在于将前沿的深度学习能力转化为直观的应用,极大地降低了AI创作的门槛。在工程实践中,开发者常使用PyTorch框架实现Gatys算法,并借助PyQt5构建图形界面,将复杂的模型封装为易用的桌面软件。本文详细解析了从VGG19特征提取、Gram矩阵计算、损 阅读详情

Just a Hook

https://vjudge.net/problem/HDU-1698
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.
在这里插入图片描述
Now Pudge wants to do some operations on the hook.

Let us number the consecutive metallic sticks of the hook from 1 to N. For each operation, Pudge can change the consecutive metallic sticks, numbered from X to Y, into cupreous sticks, silver sticks or golden sticks.
The total value of the hook is calculated as the sum of values of N metallic sticks. More precisely, the value for each kind of stick is calculated as follows:

For each cupreous stick, the value is 1.
For each silver stick, the value is 2.
For each golden stick, the value is 3.

Pudge wants to know the total value of the hook after performing the operations.
You may consider the original hook is made up of cupreous sticks.
Input
The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 10 cases.
For each case, the first line contains an integer N, 1<=N<=100,000, which is the number of the sticks of Pudge’s meat hook and the second line contains an integer Q, 0<=Q<=100,000, which is the number of the operations.
Next Q lines, each line contains three integers X, Y, 1<=X<=Y<=N, Z, 1<=Z<=3, which defines an operation: change the sticks numbered from X to Y into the metal kind Z, where Z=1 represents the cupreous kind, Z=2 represents the silver kind and Z=3 represents the golden kind.
Output
For each case, print a number in a line representing the total value of the hook after the operations. Use the format in the example.
Sample Input
1
10
2
1 5 2
5 9 3
Sample Output
Case 1: The total value of the hook is 24.
C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 100000 + 10;

struct node{
	int l, r, sum, lazy;
}segTree[MAXN << 2];

void pushup(int x)
{
	segTree[x].sum = segTree[x << 1].sum + segTree[x << 1 | 1].sum;
}

void pushdown(int x)
{
	if(segTree[x].lazy)
	{
		segTree[x << 1].lazy = segTree[x << 1 | 1].lazy = segTree[x].lazy;
		segTree[x << 1].sum = (segTree[x << 1].r - segTree[x << 1].l + 1) * segTree[x].lazy;
		segTree[x << 1 | 1].sum = (segTree[x << 1 | 1].r - segTree[x << 1 | 1].l + 1) * segTree[x].lazy;
		segTree[x].lazy = 0; 
	}
}

void build(int x, int l, int r)
{
	segTree[x].l = l;
	segTree[x].r = r;
	segTree[x].lazy = 0;
	if(l == r)
	{
		segTree[x].sum = 1;
		return;
	}
	int mid = l + r >> 1;
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	pushup(x);
}

void update(int x, int l, int r, int val)
{
	if(l <= segTree[x].l && segTree[x].r <= r)
	{
		segTree[x].sum = (segTree[x].r - segTree[x].l + 1) * val;
		segTree[x].lazy = val;
		return;
	}
	pushdown(x);
	int mid = segTree[x].l + segTree[x].r >> 1;
	if(r <= mid) update(x << 1, l, r, val);
	else if(l > mid) update(x << 1 | 1, l, r, val);
	else
	{
		update(x << 1, l, mid, val);
		update(x << 1 | 1, mid + 1, r, val);
	}
	pushup(x);
}

int query(int x, int l, int r)
{
	if(l <= segTree[x].l && segTree[x].r <= r)
		return segTree[x].sum;
	pushdown(x);
	int mid = segTree[x].l + segTree[x].r >> 1;
	if(r <= mid) return query(x << 1, l, r);
	else if(l > mid) return query(x << 1 | 1, l, r);
	else return query(x << 1, l, mid) + query(x << 1 | 1, mid + 1, r);
}

int main()
{
	int T, cnt = 1;
	scanf("%d", &T);
	while(T --)
	{
		int n, q, a, b, c;
		scanf("%d%d", &n, &q);
		build(1, 1, n);
		for(int i = 1; i <= q; i ++)
		{
			scanf("%d%d%d", &a, &b, &c);
			update(1, a, b, c);
		}
		int ans = query(1, 1, n);
		printf("Case %d: The total value of the hook is %d.\n", cnt ++, ans);
	}
	return 0;
}
HttpCanary和JustTrustMe.rar 立即下载

相关推荐

R语言实战:Scheirer–Ray–Hare检验在非正态重复测量数据分析中的应用

本文详细介绍了当重复测量数据不满足正态分布假设时,如何利用R语言中的Scheirer–Ray–Hare检验进行数据分析。该检验作为非参数方法,无需数据服从正态分布或方差齐性,适用于分析组间差异、时间效应及其交互作用。文章通过实战案例,从环境搭建、数据准备、检验执行到结果解读与可视化,提供了完整的操作指南,帮助研究者有效处理心理学、医学等领域的复杂实验数据。

salt9的博客 780

Just a Hook(线段树)

Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same lengt

codeswarrior的博客 486

【Chisel】2.4 时序逻辑

2.4 时序逻辑@[TOC](2.4 时序逻辑)前言寄存器(`Reg`)实例Chisel的状态函数实例2 RegNext实例3 RegInit移位器附录 显式的时钟信号和复位信号 前言 没有状态机的逻辑电路是不完整的,没有状态机的逻辑电路是不完整的,没有状态机的逻辑电路是不完整的,重要的事情说三遍。 这一节我们将要学习Chisel中的时序逻辑。在最后我们会实现一个移位器。 这里你需要知道的是,前面的这几节实际上都是对Chisel的基础语法的学习,它并不会给你带来很大的“惊喜”。Chisel真正的作用是把电路

快乐学习小猪猪的博客 843

Just a Hook

In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pud...

李!的博客 813

电镀技术:微型制造的原子级加法工艺与核心优势

电镀是一种利用电解原理在基材表面沉积金属层的表面处理技术,其本质是通过电场控制溶液中金属离子的迁移与还原,实现原子级的可控沉积。这一过程的核心在于对电流密度、温度、添加剂等参数的精密调控,从而实现对镀层结晶结构、性能的“编程”。从技术价值看,电镀作为一种“加法制造”工艺,在微观尺度上具有无与伦比的保形性和材料灵活性,能够实现复杂三维结构的均匀覆盖与功能复合。在应用场景上,它尤其契合现代微型化制造的需求,例如在集成电路的铜互连填充、高密度PCB板微孔金属化、MEMS传感器电极制备以及柔性电子器件制造中发挥着不

weixin_42524842的博客 528

ctfshow WEB web4

ctfshow WEB web4

weixin_68416970的博客 721

[kuangbin带你飞]专题七 线段树E - Just a Hook HDU - 1698

E - Just a Hook HDU - 1698 #include<bits/stdc++.h> using namespace std; const int M = 100000+100; int st[M<<2],lazy[M<<2]; void pushdown(int l,int r,int rt) { if(lazy[rt]) { ...

bjfu170203101的博客 269

STM32铅酸蓄电池内阻测试仪的交流阻抗测量与数据采集优化

本文深入探讨了基于STM32的铅酸蓄电池内阻测试仪设计,重点解析了交流阻抗测量原理与数据采集优化方案。通过采用1kHz交流小信号注入和数字相敏检波技术,实现对电池欧姆内阻的无损精准测量,并详细介绍了硬件前端调理、ADC过采样及系统标定等关键优化手段,有效提升了测量精度与稳定性。

weixin_29168393的博客 487

HDU-1698 Just a Hook(线段树模板,懒标记区间修改)

HDU-1698 Just a Hook /* * HDU-1698 Just a Hook * http://acm.hdu.edu.cn/showproblem.php?pid=1698 */ #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <queue> using namespace std; const

NaNa 169

【即插即用模块】Transformer篇 | CVPR 2025 | SADA:多尺度+可变形采样,完美替换自注意力实现涨点!

文章摘要 本文提出了一种尺度自适应可变形注意力模块(SADA),用于处理图像修复中的结构化伪影问题。SADA通过多尺度多头机制捕获远程依赖关系,并引入可变形采样偏移来有效处理非均匀空间分布的模式。该模块适用于底层视觉任务,可替代ViT自注意力,实验证明能显著提升性能。代码已开源,支持即插即用集成。 核心特点: 多尺度头适应不同大小的重复模式 可变形偏移优化非均匀分布采样 轻量级设计,易于集成到现有架构 适用场景:图像去噪、超分辨率等底层视觉任务。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 1431

用扩展点为 Fiori Elements 添加自定义动作:从原理到落地的完整实践

本文介绍了如何在基于OData V4的Fiori Elements应用中通过Extension Points添加自定义Action按钮。主要内容包括: 扩展点动作与标准注解动作的区别:扩展点用于非标准前端流程、组合操作等场景,需通过extensionAPI与框架交互。 扩展点动作的插入位置:可放置在List Report表格工具栏、Object Page页眉/页脚/Section工具栏等位置,并说明了相应的manifest.json配置节点。 配置模型与处理函数契约:详细说明了press、visible/e

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 250

【线段树区间更新】hdu1698 Just a Hook

【线段树区间更新】hdu1698 Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same l

xuziling_的博客 230

骑砍Ⅱ霸主MOD开发(5)-2D界面

本文介绍了2D界面开发的技术框架,主要包括以下内容: 2D界面架构:由多个GauntletLayer(菜单/对话框/定制页面)和SceneLayer(3D页面)组成,支持屏幕切换和管理。 GauntletLayer实现:采用Movie(HTML页面)+ViewModel(动态数据)模式,支持优先级管理、焦点控制和事件响应。 2D控件系统:包括颜色字体、坐标布局、背景图(Sprite/Texture)等配置方式,支持自定义控件开发。 定制化页面开发:详细说明了游戏菜单和对话框的实现方法,包括状态管理、事件回调

骑砍战团&霸主MOD开发 1182

HDU-1698-Just a Hook

HDU-1698-Just a Hook http://acm.hdu.edu.cn/showproblem.php?pid=1698 还是成段更新线段树 #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100005 struct cam { int x; int y;...

weixin_30652897的博客 87

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

线段树(成段更新)hdu 1698 Just a Hook

根据大神博客NotOnlySuccess的讲解,这个题目应该是属于线段树应用的第二阶段,也就是“成段更新”。大神博客已经有代码了,可能由于本题目不是很难所以没有过多的注释,如果是新手还是不容易看懂。所以这里就在啰嗦讲解一点吧。 题目:hdu 1698 Just a Hook 题目大意:dota中的屠夫(英雄)有一个钩子,钩子是连续的,现在假设钩子编号是从1到n,每个钩子有三种状态,分别对应的值

nyist_jiang 962

efm32 入门.pdf

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

HDU 1698 Just a Hook(线段树:区间set,区间查询)

HDU 1698 Just a Hook(线段树:区间set,区间查询) 分析:线段树区间set基本操作,详情看刘汝佳训练指南。 //HDU 1698 线段树 区间set 区间查询 #include #include #include using namespace std; #define lson i*2,l,m #define rson i*2+1,m+1,r const int MA

code 1363

hdu1698Just a Hook

http://acm.hdu.edu.cn/showproblem.php?pid=1698 裸的线段树区间更新#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace std; const int maxn=100005;struct Node { int su

skymeteorite 429

hdu 1698 Just a Hook

http://acm.hdu.edu.cn/showproblem.php?pid=1698 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21917    Accepted Submission(s)

大太阳 736

hdu 【1698】 Just a Hook

Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 25593    Accepted Submission(s): 12778 Problem Description In the game of D

你真的介意真的在乎真的想要真的渴望的话你一定能够做到 297

线段树(成段更新) HDU 1698 Just a Hook

题目传送门 1 /* 2 线段树-成段更新:第一题!只要更新区间,输出总长度就行了 3 虽然是超级裸题,但是用自己的风格写出来,还是很开心的:) 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cmath> ...

weixin_30533797的博客 66
上一篇: 第二届“传智杯”全国大学生IT技能大赛(决赛)部分题解
下一篇: ZOJ 1610 Count the Colors
剑气扬名
博客等级 码龄7年 24粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值