tmp

CF734E Anton and Tree

泪湿孤枕 提交于 2019-11-30 18:54:02
\(\mathtt{CF734E}\) \(\mathcal{Description}\) 给一棵 \(n(n\leq200000)\) 个节点的树,每个点为黑色或白色,一次操作可以使一个相同颜色的连通块变成另一种颜色,求使整棵树变成一种颜色的最少操作数。 \(\mathcal{Solution}\) 这棵树中每个点为黑点或白点,然后最后也只要求出最小操作数,对于一个联通块,我们选择其中任何一个节点进行染色的效果是一样的(都会把这个联通块变成同一个颜色),于是我们自然而然的可以想到缩点。然后样例中的树就可以是 (贺个图 \(qwq\) ) 可以看出我们把这个树从原先的树变成了一棵异层颜色相异(也就是黑白相间)的树,如果当前是一条链,我们要是最后操作数是最小的,我们一定会选择从中间开始染色,所以对于一棵树,我们只需要选择他的直径进行染色,最后的答案就是 \((直径+1)/ 2\) 。 \(\mathcal{Code}\) #include<bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, color[N]; vector<int> a[N]; inline int read() { int x = 0, k = 1; char c = getchar(); for (; c < 48 || c >

Heroku - how to write into “tmp” directory?

久未见 提交于 2019-11-30 18:25:04
I need to use the tmp folder on Heroku (Cedar) for writing some temporarily data, I am trying to do that this way: open("#{Rails.root}/tmp/#{result['filename']}", 'wb') do |file| file.write open(image_url).read end But this produce error Errno::ENOENT: No such file or directory - /app/tmp/image-2.png I am trying this code and it's running properly on localhost, but I cannot make it work on Heroku. What is the proper way to save some files to the tmp directory on Heroku (Cedar stack)? Thank you EDIT: I am running method with Delayed Jobs that needs to has access to the tmp file. EDIT2: What I

个人第3次作业:结对编程

China☆狼群 提交于 2019-11-30 17:02:58
Fork仓库的Github项目地址: https://github.com/Wamnario/PairProgramming.git PSP2.1 Personal Software Process Stages 预估耗时(分钟) Planning 计划 30 Estimate 估计这个任务需要多少时间 30 Development 开发 90 Analysis 需求分析 60 Design Spec 生成设计文档 60 Design Review 设计复审 30 Coding Standard 代码规范 60 Design 具体设计 60 Coding 具体编码 90 Code Review 代码复审 60 Test 测试 30 Reporting 报告 60 Test Report 测试报告 30 Size Measurement 计算工作量 30 Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 60 Sum 合计 780 程序设计 窗体设计 一个好的程序首先从界面的美感开始。创建好 WinForm 之后合理使用 ToolBox 里的工具进行设计。主要有对所有学生姓名、学号的存放,会用到 DataGridView .其次是随机抽取学生功能,只需要一个名为 "随机抽取" 的 Button 即可。抽取到随机学生后

标准io和管道练习

左心房为你撑大大i 提交于 2019-11-30 16:14:11
     标准IO和管道实验练习 【例1】把/etc/fstab文件内容重定向到/tmp目录下文件名为fstab.out 写法: 13:54:35 root@centos ~]#cat /etc/fstab > /tmp/fstab.out [13:55:02 root@centos ~]#cat /tmp/fstab.out # # /etc/fstab # Created by anaconda on Fri Sep 20 14:23:49 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=b7becd8b-fb18-48cf-810b-953944dcf82e / xfs defaults 0 0 UUID=a74c9411-1dd4-44ff-929d-ba505baaec2c /boot xfs defaults 0 0 UUID=cc79eddd-a461-46e9-96ab-3489b7de0db3 /data xfs defaults 0 0 UUID=23047094-ac08-4c27

【小白刷题之路Day28】leetcode394. 字符串解码(括号匹配)

依然范特西╮ 提交于 2019-11-30 15:01:40
给定一个经过编码的字符串,返回它解码后的字符串。 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次。注意 k 保证为正整数。 你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像 3a 或 2[4] 的输入。 示例: s = "3[a]2[bc]", 返回 "aaabcbc". s = "3[a2[c]]", 返回 "accaccacc". s = "2[abc]3[cd]ef", 返回 "abcabccdcdcdef". 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/decode-string 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 第一次提交代码: class Solution { public: string decodeString(string s) { stack<char> stk; string res; int i=0; while (i<s.size()){ if (s[i] == '['){ ++i; while(s[i] != ']'){ stk.push(s[i]); ++i

Store file in directory tmp on heroku Rails

99封情书 提交于 2019-11-30 14:43:12
问题 In my Delayed Job, I tried to create a file to tmp folder file_path = Rails.root.join('tmp', "#{file_name}." + file_extension); exported_file = kit.to_pdf # Save file to disk File.open(file_path, 'wb') do |file| file << exported_file end It works well in local but on Heroku there is a error in Delayed Job "No such file or directory - /app/tmp/test.pdf" So how I can solve this problem. I do not want to store file in S3. Thank you 回答1: Heroku uses what is called an ephemeral filesystem. This

数字图像处理——图像增强

ぐ巨炮叔叔 提交于 2019-11-30 13:38:58
图像增强 图像增强的目的是:改善图像的视觉效果或使图像更适合于人或机器的分析处理 \[ 图像增强 \begin{cases} 空域法 \begin{cases} 点操作 \begin{cases} 直接灰度变换\\ 直方图修正 \end{cases}\\ 邻域操作 \begin{cases} 图像平滑\\ 图像锐化 \end{cases} \end{cases}\\ 频域法 \begin{cases} 低通滤波\\ 高通滤波 \end{cases} \end{cases} \] 点操作 直接灰度变换 \(g(x,y)=T[f(x,y)]\) \(T\) => 灰度映射函数 坐标位置 \((x,y)\) 为 \(f\) 的自变量,表示当前灰度值,经过函数 \(T\) 转变为 \(g\) , 注意在T函数中 \(f(x,y)\) 为其自变量 直接灰度变换又可以分为: 线性变换 分段线性变换 非线性变换 线性变换 & 分段线性变换 对于 \(f(x,y)\) 灰度范围为 \([a,b]\) 的部分,进行线性变换 \[g(x,y) = {d-c\over b-a}[f(x,y)-a]+c\] 我们可以用它来做什么? 举个简单的例子,我们可以很容易的通过调整灰度分布,使得图片白的部分更白,黑的部分更黑 void increase(Mat &inputImage, Mat&

小明种苹果(续)第十七次CCF认证

天大地大妈咪最大 提交于 2019-11-30 13:22:28
小明种苹果(续)第十七次CCF认证 原题链接 解题思路 进行模拟即可 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int maxn=1007; struct node { ll init, dsum; bool drop; //用来记录这棵树是否发生苹果掉落 }a[maxn]; int n, m; int main() { ll tmp; scanf("%lld", &n); for(int i=1; i<=n; i++) { scanf("%d", &m); for(int j=1; j<=m; j++) { scanf("%lld", &tmp); if(j==1) //第一次要进行初始化 { a[i].init=tmp; a[i].drop=false; continue; } if(tmp>0) { if(a[i].init!=tmp) //判断是否发生苹果掉落 { a[i].dsum+=a[i].init-tmp; a[i].init=tmp; a[i].drop=true; } } else { a[i].init += tmp; //注意这个tmp是非正数 } } } ll sum=0, nums=0,

【Linux】一步一步学Linux——expr命令(265)

走远了吗. 提交于 2019-11-30 13:21:05
00. 目录 文章目录 00. 目录 01. 命令概述 02. 命令格式 03. 常用选项 04. 参考示例 05. 附录 01. 命令概述 expr命令 将表达式的值列印到标准输出。 expr命令的英文全称是“expression”,是一款表达式计算工具,使用它完成表达式的求值操作。 02. 命令格式 用法:expr 表达式  或:expr 选项 03. 常用选项 --help 显示此帮助信息并退出 --version 显示版本信息并退出 常用的表达式 可用的表达式有: ARG1 | ARG2 若ARG1 的值不为0 或者为空,则返回ARG1,否则返回ARG2 ARG1 & ARG2 若两边的值都不为0 或为空,则返回ARG1,否则返回 0 ARG1 < ARG2 ARG1 小于ARG2 ARG1 <= ARG2 ARG1 小于或等于ARG2 ARG1 = ARG2 ARG1 等于ARG2 ARG1 != ARG2 ARG1 不等于ARG2 ARG1 >= ARG2 ARG1 大于或等于ARG2 ARG1 > ARG2 ARG1 大于ARG2 ARG1 + ARG2 计算 ARG1 与ARG2 相加之和 ARG1 - ARG2 计算 ARG1 与ARG2 相减之差 ARG1 * ARG2 计算 ARG1 与ARG2 相乘之积 ARG1 / ARG2 计算 ARG1 与ARG2

WIFI 第二章 BCM WIFI CMD

老子叫甜甜 提交于 2019-11-30 13:17:12
踢掉mac地址为$mac的客户端 /bin/wl -i wl0(interface) deauthenticate $mac    #获取客户端mac地址,并写到/tmp/wl_assoclist中 /bin/wl -i wl1 assoclist | cut -f2 -d " " > /tmp/wl_assoclist    #踢掉所有的MAC地址 #Gets the client MAC address /bin/wl -i wl1 assoclist | cut -f2 -d " " > /tmp/wl_assoclist #disconnect all wifi clients to update dhcp information cat '/tmp/wl_assoclist' | while read mac do /bin/wl -i wl0 deauthenticate $mac /bin/wl -i wl1 deauthenticate $mac done    查看channel相关信息: wl -i wl0 chanspecs wl -i wl0 channel wl -i wl0 chan_info    wl -i wl0 radar 2 模拟被雷达打到 acs_cli -i wl0 msglevel 0x0684 打开acs debug acs_cli