除了将bitmap转化为int之类的,还可以直接用string.
同时可以用unordered_map<string,bool>记录状态是否访问过。
同时注意string的一个char的范围不只是0、1,因此还可以用来计数之类的
除了将bitmap转化为int之类的,还可以直接用string.
同时可以用unordered_map<string,bool>记录状态是否访问过。
同时注意string的一个char的范围不只是0、1,因此还可以用来计数之类的
vim ~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</settings>
或者:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>central repo</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>apache snapshots</mirrorOf>
<name>阿里云阿帕奇仓库</name>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</mirror>
</mirrors>
<proxies/>
<activeProfiles/>
<profiles>
<profile>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>aliyunmaven</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>MavenCentral</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>aliyunmavenApache</id>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
2. docker换源
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn", "http://hub-mirror.c.163.com","https://registry.docker-cn.com"]
}
3. gradle换源
nano ~/.gradle/init.gradle
allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/'
def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter/'
def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google/'
def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL."
remove repo
}
if (url.startsWith('https://plugins.gradle.org/m2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
remove repo
}
}
}
maven { url ALIYUN_REPOSITORY_URL }
maven { url ALIYUN_JCENTER_URL }
maven { url ALIYUN_GOOGLE_URL }
maven { url ALIYUN_GRADLE_PLUGIN_URL }
}
}
auto it = hand.begin();
while (true) {
// 假设序列x,y。it指向x
// 这个y可能是list的end
// 备份 值
int bak_val = *it;
// 移除当前it所指,执行完后it指向y。执行完后序列变成y
hand.erase(it++);
// 之前备份的值 被插到y之前,执行完后序列变成了x,y。it指向y
hand.insert(it, bak_val);
// 若y是end,则该退出了
bool bre = false;
if (it == hand.end()) {
bre = true;
}
if (bre) {
break;
}
}
dfs可以分两种,一种自上而下的将结果传递给下层,如采用already_count之类的.
第二种则是像这样:dfs()返回整个问题的答案,而一个问题可以分解为多个子问题。如果可以这样,那么这样更好,因为感觉像这样dfs更容易缕清思路。
dfs时注意记忆化。
dfs时,一种更好的实践是在父节点要向下递归时,不判断子节点是否为空。而是在访问当前节点时,判断是否为空。这种将事情推给子节点自己去判断 比较思路清晰。
dfs时超时,可考虑将原先的数据排序,看能否加快
最近继续做bfs tag的题,有了一些新的思索。
2. 在bfs时,我们使用vis来标记某个元素是否曾经访问过。在一个图中,若这种遍历边 并 判断是否曾经访问过的行为就有很多时间开销了,那我们就可以采用list来记录某个节点的边们,并将访问过的边去掉,具体题目见lc1345 跳跃游戏IV。list相关代码如下:
auto it = list.begin();
while (it != list.end()) {
int next_x = (*it);
if (!vis[next_x]) {
vis[next_x] = true;
q.push(next_x);
if (next_x == desi) {
return step;
}
list.erase(it++);
} else {
it++;
}
}
vps_new上先跑起来新的gogs:
482 docker pull gogs/gogs
489 docker run -d --name=hbbys_gogs --memory=512M --cpus=2 --restart=always -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
根据上诉代码,接着访问端口10080,接着对gogs进行配置,应看以下官方说明。注意,数据库就用sqlite,方便迁移。
接着将vps_old上的gogs文件,先压缩,接着通过scp命令传送到vps_new上。vps_new将老文件们取代/var/gogs,但/var/gogs/gogs/conf/app.ini仍用新的。
接着在app.ini中配置require_login_view=true, disalbe_registration=true
接着docker ps查看容器,接着docker restart 重启容器。
% ls env
asm_io.inc asm_io.o cdecl.h driver.c
2. 汇编模板文件:
%include "asm_io.inc"
segment .data
segment .text
global asm_main
asm_main:
enter 0, 0
pusha
popa
mov eax,0
leave
ret
3. 自己写的一键执行汇编文件的shell程序:
% cat /root/bin/exasm
if [ $# -eq 1 ]; then
nasm -o "$1.m.o" -f elf "$1"
gcc -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
./"$1.m"
mv $1.m* ~/trash/
fi
if [ $# -eq 2 ]; then
nasm -o "$1.m.o" -f elf "$1"
gcc -g -m32 -o "$1.m" "$2" asm_io.o "$1.m.o"
./"$1.m"
#mv "$1.m" ~/trash
#mv "$1.m.o" ~/trash/
fi
4. 一般是这样运行汇编的:
% ls
asm_io.inc asm_io.o cdecl.h driver.c env lab1.asm m_temp.asm
% exasm lab1.asm
5. debug汇编程序
5.1 生成反汇编文件,
% cat /root/bin/asm_gen_out
if [ $# -eq 1 ]; then
nasm -o "$1.m.o" -f elf "$1"
gcc -g -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
objdump -S "$1.m" > "$1.m.dis_asm"
fi
% asm_gen_out lab1.asm
% ls
asm_io.asm asm_io.o driver.c lab1.asm.m lab1.asm.m.o
asm_io.inc cdecl.h lab1.asm lab1.asm.m.dis_asm m_temp.asm
接着可以打开xxx.m.dis_asm看反汇编文件,可以看到指令的地址。可以通过vim搜索asm_main函数。
5.2 gdb调试汇编程序
% cat /root/bin/asm_debug
if [ $# -eq 1 ]; then
nasm -o "$1.m.o" -f elf "$1"
gcc -g -m32 -o "$1.m" driver.c asm_io.o "$1.m.o"
gdb "$1.m"
fi
% asm_debug lab1.asm
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/pro/as/pcasl-linux/wut_asm/lab1.asm.m...done.
(gdb)
可以通过如 b *0x80bbef在某个地址断点。可以通过si单步调试。
(gdb) b *0x80487d5
Breakpoint 1 at 0x80487d5
(gdb) c
The program is not being run.
(gdb) r
Starting program: /root/pro/as/pcasl-linux/wut_asm/lab1.asm.m
Breakpoint 1, 0x080487d5 in asm_main ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.i686
(gdb) si
0x080487da in asm_main ()
->setStyleSheet("border-image:url(static/img/1.png);");