Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
contest_exercises_template
提交
719863f3
C
contest_exercises_template
项目概览
CSDN 技术社区
/
contest_exercises_template
通知
79
Star
2
Fork
18
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
4
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
contest_exercises_template
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
719863f3
编写于
1月 06, 2023
作者:
张
张志晨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add exercises
上级
4ab59f57
变更
88
隐藏空白更改
内联
并排
Showing
88 changed file
with
661 addition
and
0 deletion
+661
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/exercies.md
exercises/生产队的刘同学/中等/《教父》家族关系维护/exercies.md
+31
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/solution.cpp
exercises/生产队的刘同学/中等/《教父》家族关系维护/solution.cpp
+39
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.out
+6
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.in
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.in
+2
-0
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.out
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.out
+6
-0
exercises/生产队的刘同学/中等/寻找宝藏山/exercies.md
exercises/生产队的刘同学/中等/寻找宝藏山/exercies.md
+40
-0
exercises/生产队的刘同学/中等/寻找宝藏山/solution.cpp
exercises/生产队的刘同学/中等/寻找宝藏山/solution.cpp
+71
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.in
+6
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.in
+4
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.in
+12
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.in
+5
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.in
+5
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.in
+5
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.in
+5
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.in
+8
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.in
+5
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.out
+2
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.in
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.in
+4
-0
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.out
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.out
+2
-0
exercises/生产队的刘同学/困难/柯里昂家族树/exercies.md
exercises/生产队的刘同学/困难/柯里昂家族树/exercies.md
+61
-0
exercises/生产队的刘同学/困难/柯里昂家族树/solution.cpp
exercises/生产队的刘同学/困难/柯里昂家族树/solution.cpp
+64
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.in
+7
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.out
+6
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.in
+5
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.out
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.in
+3
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.out
+2
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.in
+5
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.out
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.in
+5
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.out
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.in
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.out
+3
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.in
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.out
+3
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.in
+5
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.out
+4
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.in
+6
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.out
+5
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.in
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.in
+7
-0
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.out
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.out
+6
-0
exercises/生产队的刘同学/简单/山洞珍宝/exercies.md
exercises/生产队的刘同学/简单/山洞珍宝/exercies.md
+34
-0
exercises/生产队的刘同学/简单/山洞珍宝/solution.cpp
exercises/生产队的刘同学/简单/山洞珍宝/solution.cpp
+30
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.out
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.in
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.in
+2
-0
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.out
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.out
+2
-0
未找到文件。
exercises/生产队的刘同学/中等/《教父》家族关系维护/exercies.md
0 → 100644
浏览文件 @
719863f3
# 《教父》家族关系维护
在《教父》中,有五个家族,分别是Corleone家族、Tattaglia家族、Cuneo家族、Stracci家族和Barzini家族。五个家族之间的关系是复杂的,它们之间可能存在敌对关系、盟友关系和中立关系。
你需要写一个程序来计算五个家族之间的关系。你需要输入五个家族之间的关系,然后输出五个家族之间的关系矩阵。
你需要自定义一个算法来计算五个家族之间的关系,算法的输入是五个家族之间的关系,输出是五个家族之间的关系矩阵。
算法的实现方式是你自己决定的,但你需要考虑这道题的时间复杂度和空间复杂度。
## 输入格式
输入第一行包含五个整数,分别表示Corleone家族、Tattaglia家族、Cuneo家族、Stracci家族和Barzini家族之间的关系。整数的取值范围是-1、0、1,分别表示敌对关系、中立关系和盟友关系。
## 输出格式
输出五行,每行五个整数,分别表示Corleone家族、Tattaglia家族、Cuneo家族、Stracci家族和Barzini家族之间的关系。整数的取值范围是-1、0、1,分别表示敌对关系、中立关系和盟友关系。
## 输入样例
1 -1 0 0 -1
## 输出样例
1 -1 0 0 -1
-1 1 0 0 1
0 0 1 0 0
0 0 0 1 0
-1 1 0 0 1
## 提示
无
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/solution.cpp
0 → 100644
浏览文件 @
719863f3
#include <iostream>
#include <sstream>
using
namespace
std
;
const
int
N
=
5
;
int
a
[
N
][
N
];
int
main
()
{
string
line
;
getline
(
cin
,
line
);
stringstream
ss
(
line
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
N
;
j
++
)
{
if
(
i
==
j
)
{
a
[
i
][
j
]
=
1
;
// 同家族之间是盟友关系
}
else
{
a
[
i
][
j
]
=
0
;
// 默认是中立关系
}
}
}
// 从输入中读入五个家族之间的关系
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
ss
>>
a
[
i
][
i
];
}
// 输出五个家族之间的关系矩阵
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
N
;
j
++
)
{
cout
<<
a
[
i
][
j
]
<<
' '
;
}
cout
<<
endl
;
}
return
0
;
}
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.in
0 → 100644
浏览文件 @
719863f3
1 -1 0 0 -1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/1.out
0 → 100644
浏览文件 @
719863f3
1 -1 0 0 -1
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1 0 0 0 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.in
0 → 100644
浏览文件 @
719863f3
-1 1 -1 1 -1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/10.out
0 → 100644
浏览文件 @
719863f3
1 -1 1 -1 1
-1 1 -1 1 -1
1 -1 1 -1 1
-1 1 -1 1 -1
1 -1 1 -1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.in
0 → 100644
浏览文件 @
719863f3
1 1 1 1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/2.out
0 → 100644
浏览文件 @
719863f3
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.in
0 → 100644
浏览文件 @
719863f3
-1 -1 -1 -1 -1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/3.out
0 → 100644
浏览文件 @
719863f3
1 -1 -1 -1 -1
-1 1 -1 -1 -1
-1 -1 1 -1 -1
-1 -1 -1 1 -1
-1 -1 -1 -1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.in
0 → 100644
浏览文件 @
719863f3
1 0 0 0 0
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/4.out
0 → 100644
浏览文件 @
719863f3
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.in
0 → 100644
浏览文件 @
719863f3
-1 0 0 0 0
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/5.out
0 → 100644
浏览文件 @
719863f3
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.in
0 → 100644
浏览文件 @
719863f3
0 0 0 0 0
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/6.out
0 → 100644
浏览文件 @
719863f3
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.in
0 → 100644
浏览文件 @
719863f3
1 -1 1 -1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/7.out
0 → 100644
浏览文件 @
719863f3
1 -1 1 -1 1
-1 1 -1 1 -1
1 -1 1 -1 1
-1 1 -1 1 -1
1 -1 1 -1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.in
0 → 100644
浏览文件 @
719863f3
1 1 1 1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/8.out
0 → 100644
浏览文件 @
719863f3
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.in
0 → 100644
浏览文件 @
719863f3
-1 -1 -1 -1 -1
\ No newline at end of file
exercises/生产队的刘同学/中等/《教父》家族关系维护/test_cases/9.out
0 → 100644
浏览文件 @
719863f3
1 -1 -1 -1 -1
-1 1 -1 -1 -1
-1 -1 1 -1 -1
-1 -1 -1 1 -1
-1 -1 -1 -1 1
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/exercies.md
0 → 100644
浏览文件 @
719863f3
# 寻找宝藏山
一天,你去了一个神秘的森林,在那里你遇到了一个神秘的老人。他告诉你,森林里有一座宝藏山,但是要想到达宝藏山,你必须先通过一些森林的入口。
这个老人给你了一张地图,地图上有若干个入口和宝藏山,每个入口都有一个花费。你可以从任意一个入口开始,然后经过一些入口,最终到达宝藏山。但是你有一个限制,你只能走 $K$ 步,如果走的步数超过了 $K$,那么你就无法到达宝藏山,也就无法获得宝藏。
你必须实现一个程序,接受用户输入的地图信息,并计算出,你能够到达宝藏山的最小花费。
## 输入描述
第一行包含三个整数 $N$、$M$ 和 $K$,$N$ 表示入口的个数、$M$ 表示边的个数、$K$ 表示最多走的步数。
接下来 $M$ 行,每行包含三个整数 $A$、$B$ 和 $C$,表示一条从 $A$ 到 $B$ 的有向边,边权为 $C$。
## 输出描述
输出一行,包含一个整数,表示你能够到达宝藏山的最小花费。
## 输入样例
5 10 6
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
5 2 3
2 3 4
2 1 1
2 3 4
3 4 5
## 输出样例
1061109567
## 提示
无
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/solution.cpp
0 → 100644
浏览文件 @
719863f3
#include <iostream>
#include <cstring>
#include <queue>
#include <climits>
using
namespace
std
;
const
int
N
=
1e3
+
10
,
M
=
2e6
+
10
;
int
h
[
N
],
e
[
M
],
ne
[
M
],
w
[
M
],
idx
;
int
dist
[
N
];
int
n
,
m
,
k
;
bool
st
[
N
];
// 标记数组
// 初始化
void
init
()
{
memset
(
h
,
-
1
,
sizeof
h
);
idx
=
0
;
}
// 添加一条边
void
add
(
int
a
,
int
b
,
int
c
)
{
e
[
idx
]
=
b
,
w
[
idx
]
=
c
,
ne
[
idx
]
=
h
[
a
],
h
[
a
]
=
idx
++
;
}
// Dijkstra 算法求最短路径
void
dijkstra
(
int
s
)
{
memset
(
dist
,
0x3f
,
sizeof
dist
);
dist
[
s
]
=
0
;
priority_queue
<
pair
<
int
,
int
>>
q
;
// 小根堆
q
.
push
({
0
,
s
});
while
(
q
.
size
())
{
auto
t
=
q
.
top
();
q
.
pop
();
int
ver
=
t
.
second
,
distance
=
t
.
first
;
if
(
st
[
ver
])
continue
;
st
[
ver
]
=
true
;
// 更新所有 ver 相邻的点
for
(
int
i
=
h
[
ver
];
~
i
;
i
=
ne
[
i
])
{
int
j
=
e
[
i
];
if
(
dist
[
j
]
>
distance
+
w
[
i
])
{
dist
[
j
]
=
distance
+
w
[
i
];
q
.
push
({
dist
[
j
],
j
});
}
}
}
}
int
main
()
{
// 读入
scanf
(
"%d%d%d"
,
&
n
,
&
m
,
&
k
);
init
();
// 建图
while
(
m
--
)
{
int
a
,
b
,
c
;
scanf
(
"%d%d%d"
,
&
a
,
&
b
,
&
c
);
add
(
a
,
b
,
c
);
}
// 求最短路径
dijkstra
(
1
);
// 输出最短路径
printf
(
"%d
\n
"
,
dist
[
n
]);
return
0
;
}
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.in
0 → 100644
浏览文件 @
719863f3
2 4 7
2 3 4
2 3 4
1 2 3
4 5 6
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/1.out
0 → 100644
浏览文件 @
719863f3
3
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.in
0 → 100644
浏览文件 @
719863f3
1 2 3
2 4 6
3 4 9
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/10.out
0 → 100644
浏览文件 @
719863f3
0
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.in
0 → 100644
浏览文件 @
719863f3
5 10 6
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
5 2 3
2 3 4
2 1 1
2 3 4
3 4 5
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/2.out
0 → 100644
浏览文件 @
719863f3
1061109567
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.in
0 → 100644
浏览文件 @
719863f3
3 3 40
1 2 3
2 3 4
5 3 2
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/3.out
0 → 100644
浏览文件 @
719863f3
7
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.in
0 → 100644
浏览文件 @
719863f3
3 3 40
1 2 3
2 3 3
5 6 7
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/4.out
0 → 100644
浏览文件 @
719863f3
6
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.in
0 → 100644
浏览文件 @
719863f3
2 4 30
5 1 2
5 2 2
5 3 2
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/5.out
0 → 100644
浏览文件 @
719863f3
7
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.in
0 → 100644
浏览文件 @
719863f3
6 3 4
2 1 4
3 4 2
1 2 1
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/6.out
0 → 100644
浏览文件 @
719863f3
1061109567
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.in
0 → 100644
浏览文件 @
719863f3
3 6 5
1 2 3
2 3 6
5 3 1
5 1 2
5 2 2
5 2 2
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/7.out
0 → 100644
浏览文件 @
719863f3
9
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.in
0 → 100644
浏览文件 @
719863f3
1 3 5
3 9 0
2 4 0
4 1 2
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/8.out
0 → 100644
浏览文件 @
719863f3
0
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.in
0 → 100644
浏览文件 @
719863f3
2 2 5
2 3 4
1 2 3
\ No newline at end of file
exercises/生产队的刘同学/中等/寻找宝藏山/test_cases/9.out
0 → 100644
浏览文件 @
719863f3
3
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/exercies.md
0 → 100644
浏览文件 @
719863f3
# 柯里昂家族树
在《教父》中,柯里昂家族是一个著名的黑手党家族,由家族的首领柯里昂(Don Corleone)和他的四个儿子构成。柯里昂家族的家谱是一棵二叉树,其中柯里昂是根节点,他的儿子们分别是他的左儿子和右儿子。
现在,你需要编写一个程序,读入一个包含若干行的字符串,每行表示一个人的信息。每行的格式如下:
<人物名称>
is the
<父亲名称>
's
<儿子>
其中,人物名称是一个不包含空格的字符串,父亲名称和儿子也是一个不包含空格的字符串。
例如,下面是一棵柯里昂家族的家谱:
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Michael Corleone is the Don's son
Tom Hagen is the Don's adopted son
你的程序需要按照这些信息建立一棵二叉树,并输出这棵树的前序遍历。
例如,对于上面的家谱,输出应该是:
Don Corleone Fredo Corleone Michael Corleone Tom Hagen
你的程序需要支持以下功能:
-
建立二叉树。你需要定义一个结构体表示一个节点,包含人物名称、左儿子和右儿子三个字段。你需要编写一个函数,读入若干行字符串,根据字符串中的信息建立二叉树。
-
输出前序遍历。你需要编写一个函数,输出给定二叉树的前序遍历。
## 输入格式
输入的第一行包含一个整数 n(1 <= n <= 1000),表示字符串的行数。
接下来的 n 行,每行包含一个字符串,表示一个人的信息。字符串的格式如上文所述。
## 输出格式
输出给定二叉树的前序遍历,每个人物名称占一行。
## 输入样例
4
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Michael Corleone is the Don's son
Tom Hagen is the Don's adopted son
## 输出样例
Don Corleone
Fredo Corleone
Michael Corleone
Tom Hagen
## 提示
1.
人物名称和父亲名称均由不超过 100 个字符组成,且不包含空格;
2.
儿子的值可能是 "son" 或 "adopted son";
3.
输入中可能会出现重名的人物,你的程序需要处理这种情况;
4.
输入的字符串保证是合法的,不会出现父亲名称找不到的情况。
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/solution.cpp
0 → 100644
浏览文件 @
719863f3
#include <iostream>
#include <unordered_map>
using
namespace
std
;
//定义结构体表示一个节点
struct
Node
{
string
name
;
Node
*
left
;
Node
*
right
;
};
//建立二叉树的函数
Node
*
build_tree
(
int
n
)
{
// 建立根节点
string
line
;
getline
(
cin
,
line
);
stringstream
ss
(
line
);
string
name
,
is
,
the
,
father
,
s
;
ss
>>
name
>>
is
>>
the
>>
father
>>
s
;
Node
*
root
=
new
Node
{
name
,
nullptr
,
nullptr
};
// 建立剩余的节点
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
getline
(
cin
,
line
);
stringstream
ss
(
line
);
string
name
,
is
,
the
,
father
,
s
;
ss
>>
name
>>
is
>>
the
>>
father
>>
s
;
Node
*
cur
=
root
;
while
(
true
)
{
if
(
father
==
cur
->
name
&&
s
==
"son"
)
{
if
(
cur
->
left
==
nullptr
)
{
cur
->
left
=
new
Node
{
name
,
nullptr
,
nullptr
};
break
;
}
else
if
(
cur
->
right
==
nullptr
)
{
cur
->
right
=
new
Node
{
name
,
nullptr
,
nullptr
};
break
;
}
else
{
cur
=
cur
->
left
;
}
}
else
{
cur
=
cur
->
right
;
}
}
}
return
root
;
}
//输出前序遍历的函数
void
preorder
(
Node
*
root
)
{
cout
<<
root
->
name
<<
" "
;
if
(
root
->
left
!=
nullptr
)
preorder
(
root
->
left
);
if
(
root
->
right
!=
nullptr
)
preorder
(
root
->
right
);
}
int
main
()
{
int
n
;
cin
>>
n
;
cin
.
ignore
();
Node
*
root
=
build_tree
(
n
);
preorder
(
root
);
return
0
;
}
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.in
0 → 100644
浏览文件 @
719863f3
5
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Michael Corleone is the Don's son
Tom Hagen is the Don's adopted son
Santino Corleone is the Michael's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/1.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Michael Corleone
Tom Hagen
Santino Corleone
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.in
0 → 100644
浏览文件 @
719863f3
3
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Tom Hagen is the Fredo's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/10.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.in
0 → 100644
浏览文件 @
719863f3
1
Don Corleone is the Don's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/2.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.in
0 → 100644
浏览文件 @
719863f3
3
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Tom Hagen is the Fredo's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/3.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.in
0 → 100644
浏览文件 @
719863f3
3
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Tom Hagen is the Don's adopted son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/4.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.in
0 → 100644
浏览文件 @
719863f3
2
Don Corleone is the Don's son
Michael Corleone is the Don's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/5.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Michael Corleone
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.in
0 → 100644
浏览文件 @
719863f3
2
Don Corleone is the Don's son
Tom Hagen is the Don's adopted son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/6.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.in
0 → 100644
浏览文件 @
719863f3
3
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Tom Hagen is the Don's adopted son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/7.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.in
0 → 100644
浏览文件 @
719863f3
4
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Michael Corleone is the Don's son
Tom Hagen is the Don's adopted son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/8.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Michael Corleone
Tom Hagen
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.in
0 → 100644
浏览文件 @
719863f3
5
Don Corleone is the Don's son
Fredo Corleone is the Don's son
Michael Corleone is the Don's son
Tom Hagen is the Don's adopted son
Santino Corleone is the Michael's son
\ No newline at end of file
exercises/生产队的刘同学/困难/柯里昂家族树/test_cases/9.out
0 → 100644
浏览文件 @
719863f3
Don Corleone
Fredo Corleone
Michael Corleone
Tom Hagen
Santino Corleone
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/exercies.md
0 → 100644
浏览文件 @
719863f3
# 山洞珍宝
在一端山路中,有一个神秘的山洞。这个山洞里有许多神奇的宝藏。
你在山洞外发现了一个奇怪的墙壁,上面有一个神秘的符号,你需要通过一定的方法来解码这个符号,只有解码这个符号后你才能进入这个山洞。
经过一番推导,你发现这个符号是一个由 0 和 1 组成的字符串,每个字符都有一个权值,分别是 $0,1,2,3,4,5,6,7,8,9$。
你需要从这个字符串中找到一个最大的子串,使得该子串的权值之和最大。
给定一个字符串 $S$,其长度不超过 $10^5$,且只包含字符 '0' 和 '1'。
请你找到字符串 $S$ 中权值和最大的子串。
## 输入描述
第一行包含一个字符串 $S$。
## 输出描述
输出一行,包含一个整数,表示最大的子串的权值和。
## 输入样例
0110100110110100
## 输出样例
35
## 提示
无
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/solution.cpp
0 → 100644
浏览文件 @
719863f3
#include <iostream>
#include <string>
using
namespace
std
;
const
int
N
=
1e5
+
10
;
int
sum
[
N
];
// sum[i] 表示字符串 s 的前 i 个字符的权值和
int
main
()
{
string
s
;
cin
>>
s
;
int
n
=
s
.
size
();
// 计算权值和
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sum
[
i
+
1
]
=
sum
[
i
]
+
(
s
[
i
]
-
'0'
);
int
ans
=
0
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
i
+
1
;
j
<=
n
;
j
++
)
{
// 计算字符串 s[i...j] 的权值和
int
w
=
sum
[
j
]
-
sum
[
i
];
ans
=
max
(
ans
,
w
);
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.in
0 → 100644
浏览文件 @
719863f3
01010101010
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/1.out
0 → 100644
浏览文件 @
719863f3
5
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.in
0 → 100644
浏览文件 @
719863f3
100000000010000000001
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/10.out
0 → 100644
浏览文件 @
719863f3
3
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.in
0 → 100644
浏览文件 @
719863f3
111110000101010101101000011
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/2.out
0 → 100644
浏览文件 @
719863f3
14
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.in
0 → 100644
浏览文件 @
719863f3
1010101000001111010101001
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/3.out
0 → 100644
浏览文件 @
719863f3
12
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.in
0 → 100644
浏览文件 @
719863f3
111111100000000011010101001101
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/4.out
0 → 100644
浏览文件 @
719863f3
15
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.in
0 → 100644
浏览文件 @
719863f3
11111110000000000
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/5.out
0 → 100644
浏览文件 @
719863f3
7
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.in
0 → 100644
浏览文件 @
719863f3
10101010101001011111111
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/6.out
0 → 100644
浏览文件 @
719863f3
15
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.in
0 → 100644
浏览文件 @
719863f3
1111110010101010010
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/7.out
0 → 100644
浏览文件 @
719863f3
11
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.in
0 → 100644
浏览文件 @
719863f3
1111000001010101010
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/8.out
0 → 100644
浏览文件 @
719863f3
9
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.in
0 → 100644
浏览文件 @
719863f3
100101010100101010
\ No newline at end of file
exercises/生产队的刘同学/简单/山洞珍宝/test_cases/9.out
0 → 100644
浏览文件 @
719863f3
8
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录