各种杂物

长如狗的程序头

/*
ID:wjp13241
PROG:
LANG:C++
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define dfo(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,x,e) for(int i=ls[x];i;i=e[i].next)
#define fil(x,t) memset(x,t,sizeof(x))
#define FILEIN(s) freopen(s,"r",stdin)
#define FILEOUT(s) freopen(s,"w",stdout)
#define STP system("pause")
#define min(x,y) x<y?x:y
#define max(x,y) x>y?x:y
#define MP(x,y) make_pair(x,y)
#define PuB(v,x) v.push_back(x)
#define PoB(v) v.pop_back()
#define ld long double
#define ll long long
#define db double
#define INF 0x3f3f3f3f
#define LIM 100000000
#define EPS 1e-4
#define N 100201
#define E N*20+1
#define L 21
using namespace std;

读入优化

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

输出优化

inline void write(ll x){
	char ch[L]={};int i=0;
	if (x<0) putchar('-');
	do{ch[++i]='0'+x%10;}while (x/=10);
	while (i)putchar(ch[i--]);
	putchar('\n');
}

随机数

#include <ctime>
using namespace std;
inline int get(int x){return rand()%x;}
int main()
{
	srand((unsigned)time(NULL));
	int n=get(32767);
	return 0;
}

sublime设置

{
	"draw_white_space": "all",
	"bold_folder_labels": true,
	"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
	"font_face": "roboto mono medium",
	"font_size": 12,
	"highlight_line": true,
	"highlight_modified_tabs": true,
	"ignored_packages":
	[
		"Vintage"
	],
	"line_padding_bottom": 1,
	"line_padding_top": 1,
	"material_theme_tree_headings": true,
	"overlay_scroll_bars": "enabled",
	"theme": "Material-Theme.sublime-theme",
	"word_wrap": true
}

vimrc

set nu
set autoindent
set cindent
set smartindent
set guifont=roboto_mono_medium:h10:b:cDEFAULT
set ruler
syntax on
filetype on
inoremap ( ()<Esc>i
		inoremap [ []<Esc>i
		inoremap { {<CR>}<Esc>O
		autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
		inoremap ) <c-r>=ClosePair(')')<CR>
		inoremap ] <c-r>=ClosePair(']')<CR>
		inoremap } <c-r>=CloseBracket()<CR>
		inoremap " <c-r>=QuoteDelim('"')<CR>
		inoremap ' <c-r>=QuoteDelim("'")<CR>

		function ClosePair(char)
	 if getline('.')[col('.') - 1] == a:char
	  return "\<Right>"
	   else
	    return a:char
	     endif
	     endf

	     function CloseBracket()
	 if match(getline(line('.') + 1), '\s*}') < 0
	  return "\<CR>}"
	   else
	    return "\<Esc>j0f}a"
	     endif
	     endf

	     function QuoteDelim(char)
	 let line = getline('.')
	  let col = col('.')
	   if line[col - 2] == "\\"
	    return a:char
	     elseif line[col - 1] == a:char
	      return "\<Right>"
	       else
	        return a:char.a:char."\<Esc>i"
		 endif
		 endf

win对拍

:loop
data.exe
std.exe
myp.exe
fc std.out myp.out
if errorlevel 1 goto end
goto loop
:end
pause

##linux对拍

#!bin/bash
while true;
do
./data
./std
./myp
if diff std.out myp.out;then
echo AC
else
echo WA
exit 0
fi
done

C++对拍


终于还是学习了C++对拍的姿势,这样写可以比较时间而且win下和linux下都能跑,非常优秀

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <ctime>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

int main(void) {
    std:: ios:: sync_with_stdio(false);
    rep(i,1,100000) {
        printf("%d ",i);
        system("./data");
        double tt=clock();
        system("./std");
        std:: cout<<clock()-tt<<' ';
        tt=clock();
        system("./myp");
        std:: cout<<clock()-tt<<' ';
        if (system("diff std.out myp.out > NULL")==0) puts("AC");
        else {
            puts("WA");
            return 0;
        }
    }
    return 0;
}

gdb调试命令


晚年更博系列
格式:命令/缩写:作用,用法

run/r:没啥好说的
quit/q:没啥好说的
print/p:没啥好说的
break/b:设置断点 ,举例:break 45
whatis:显示变量类型 ,举例:whatis p
finish:运行直到当前过程结束 ,举例:finish
continue:跳至下一个断点 ,举例:continue
call:运行某一函数,举例 :call read()
set variable:变量赋值

构建目标检测系统以识别灭火器、火焰、烟雾,并将其他所有物体归类为杂物,可以按照以下步骤进行: ### 数据准备 收集包含灭火器、火焰、烟雾以及各种杂物的图像数据集。对于每个类别,需要确保有足够的样本量以覆盖不同的场景、光照条件、角度等。数据集应分为训练集、验证集和测试集。数据增强技术(如旋转、翻转、裁剪、调整亮度等)可以用来增加数据的多样性。 ### 标注数据 使用标注工具(如LabelImg或CVAT)对图像中的灭火器、火焰、烟雾进行边界框标注,而其他所有物体则统一标记为杂物。标注的边界框应尽可能紧密地包围目标对象。 ### 模型选择 选择适合多类别目标检测的深度学习模型,如Faster R-CNN、YOLO(You Only Look Once)系列或SSD(Single Shot MultiBox Detector)。由于需要将其他所有物体归类为杂物,因此模型的输出层应包含四个类别:灭火器、火焰、烟雾和杂物。 ### 模型训练 使用准备好的数据集对选定的模型进行训练。在训练过程中,使用交叉熵损失函数来优化模型参数,并通过验证集监控模型的性能以防止过拟合。可以使用预训练的模型作为起点,通过迁移学习来加速训练过程并提高模型性能。 ### 模型评估 在测试集上评估模型的性能,主要关注精确度(Precision)、召回率(Recall)和平均精度(mAP)。对于杂物类别,虽然不需要特别高的精度,但仍需确保其不会对其他三个类别的检测造成干扰。 ### 部署与应用 一旦模型训练完成并通过了评估,就可以将其部署到实际的应用环境中。这可能涉及到将模型转换为适合特定硬件平台的格式,并编写相应的代码来处理实时视频流或图像输入。 ### 示例代码 下面是一个使用PyTorch实现的简单Faster R-CNN模型定义的例子: ```python import torchvision from torchvision.models.detection.faster_rcnn import FastRCNNPredictor # 加载预训练的Faster R-CNN模型 model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True) # 替换分类器,输出四个类别:灭火器、火焰、烟雾和杂物 num_classes = 4 # 包括背景 in_features = model.roi_heads.box_predictor.cls_score.in_features model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes) ``` 这段代码加载了一个预训练的Faster R-CNN模型,并替换了最后的分类器层以适应新的类别数。在实际应用中,还需要编写数据加载、训练循环、评估指标等部分。 ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值