Skip to content

Commit 9621f16

Browse files
committed
feat: done 2021f/lab6
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
1 parent 73adba2 commit 9621f16

47 files changed

Lines changed: 1430 additions & 13 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717

1818
人工干预: contest目录中实现README, 获取cid, 题目信息
1919

20-
copilot 实现: 按照cid, 拉取题目信息
20+
copilot-拉取: 按照cid, 拉取题目信息
2121

22-
copilot 实现: 按照题目信息, 写入子目录中, 各个题目的README中
22+
copilot-获取题面: 按照题目信息, 写入子目录中, 各个题目的README中
2323

24-
copilot 实现: 在README中, 根据句点`.`, 每一句话一个段落, 在不改变原始文字的情况下, 将长段落分为短段落
24+
copilot-优化README: 在README中, 根据句点`.`, 每一句话一个段落, 在不改变原始文字的情况下, 将长段落分为短段落
2525

26-
copilot 实现: 将题目格式化, 将 `\\`等符号替换为 标准Latex符号`$`, 实现符号渲染正常
26+
copilot-公式优化: 将题目格式化, 将 `\\`等符号替换为 标准Latex符号`$`, 实现符号渲染正常
2727

2828
## 题目实现流程
2929

30-
copilot 实现: 读取目录中的 README.md 题面实现到 main.cpp 中
30+
copilot-生成: 读取目录中的 README.md 题面实现到 main.cpp 中(显然目标语言是C++)
3131

32-
copilot 实现: 读取 README.md 中的样例输入输出, 检测与目录内 resource 目录下的 `01.data.in`, `01.data.out`是否相同, 不相同则覆盖写
32+
copilot-检查样例: 读取 README.md 中的样例输入输出, 检测与目录内 resource 目录下的 `01.data.in`, `01.data.out`是否相同, 不相同则覆盖写
3333

34-
copilot 实现: 生成代码后, 不需要编译, 直接调用 hustoj-mcp, 将其上传到 hustoj 中.
34+
copilot-上传: 生成代码后, 不需要编译, 直接调用 hustoj-mcp, 将其上传到 hustoj 中.
3535

36-
copilot 实现: 按照 README.md 结合 main.cpp 的实现, 写出分析到 README.md 的最后
36+
copilot-解释算法: 按照 README.md 结合 main.cpp 的实现, 写出算法分析到 README.md 的最后
3737

3838
## 代码撰写原则
3939

@@ -43,11 +43,9 @@ copilot 实现: 按照 README.md 结合 main.cpp 的实现, 写出分析到 READ
4343
4. 尽量使用 STL 标准库内的算法
4444
5. 使用函数进行模块化
4545
6. 使用注释进行代码说明
46-
7. 使用统一的代码风格
47-
8. 使用输入-处理-输出三段式风格
48-
9. 禁止使用 `#include <bits/stdc++.h>`
49-
10. 保留原有main.cpp结构
50-
11. 尽量使用 `int32`, `int64`等定长类型, 不使用`long` `long long`等类型
46+
7. 使用统一的代码风格: main.cpp 的 输入-处理-输出三段式风格
47+
8. 禁止使用 `#include <bits/stdc++.h>`
48+
9. 尽量使用 `int32`, `int64`等定长类型
5149

5250
### README format
5351

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.16.6)
2+
set(PROJECT_ORDER lab_06)
3+
project(${PROJECT_NAME}_${PROJECT_ORDER})
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
7+
8+
enable_testing()
9+
set(dependencies A B C D E F G)
10+
foreach (elementName IN LISTS dependencies)
11+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_ORDER}_${elementName})
12+
endforeach ()
13+
unset(dependencies)

algorithm/2021F/lab_06/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contest1101 - CS203 2021 Fall Lab 06 String
2+
3+
> cid: 1102
4+
5+
Welcome to CS203 2021 Fall Lab 06! Enjoy this Lab!
6+
7+
There are six problems for you to solve.
8+
9+
Score:
10+
11+
+ A: 10
12+
+ B: 15/10
13+
+ C: 15/10
14+
+ D: 20/15
15+
+ E: 20/15
16+
+ F: 20
17+
+ G: undefined/20
18+
19+
Reading the samples and hints carefully can help you understand the problem.
20+
21+
## 题目列表
22+
23+
| Problem | problem id |
24+
|--------:|-----------:|
25+
| A | 1446 |
26+
| B | 1447 |
27+
| C | 1448 |
28+
| D | 1449 |
29+
| E | 1450 |
30+
| F | 1452 |
31+
| G | 1451 |
32+
33+
B, F被复用, 无法测试, 故不实现
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
problem, AC, PE, WA, TLE, MLE, OLE, RE, CE, TR, Total , C, C++, Java
2+
A, 233, 114, 3, 8, 5, 10, 33, 406, 10, 81, 315
3+
B, 253, 2, 99, 152, 11, 26, 50, 593, 20, 113, 460
4+
C, 247, 7, 137, 304, 2, 9, 45, 42, 1, 794, 27, 205, 562
5+
D, 236, 246, 152, 7, 7, 36, 27, 711, 16, 101, 594
6+
E, 235, 277, 318, 28, 9, 46, 49, 962, 9, 234, 719
7+
F, 225, 407, 253, 2, 11, 76, 34, 1008, 14, 159, 835
8+
Total, 1429, 9, 1280, 1182, 58, 41, 239, 235, 1, 4474, 96, 893, 3485
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
problem, AC, PE, WA, TLE, MLE, OLE, RE, CE, TR, Total , C, C++, Java
2+
A, 27, 5, 1, 4, 37, 1, 20, 16
3+
B, 32, 8, 7, 4, 5, 56, 1, 31, 24
4+
C, 38, 1, 8, 31, 8, 4, 90, 1, 48, 41
5+
D, 38, 20, 6, 8, 1, 73, 49, 24
6+
E, 30, 31, 23, 4, 9, 5, 102, 42, 60
7+
F, 28, 16, 6, 1, 9, 6, 66, 26, 40
8+
G, 39, 26, 7, 2, 2, 76, 1, 44, 31
9+
Total, 232, 1, 114, 80, 4, 3, 39, 27, 500, 4, 260, 236
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.16.6)
2+
set(PROBLEM_ORDER A)
3+
project(${PROJECT_NAME}_${PROBLEM_ORDER})
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
7+
8+
enable_testing()
9+
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
10+
set(CMAKE_CXX_STANDARD 17)
11+
add_executable(${PROJECT_NAME}_test ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp)
12+
target_compile_definitions(${PROJECT_NAME}_test PRIVATE ALGORITHM_TEST_MACRO)
13+
target_link_libraries(${PROJECT_NAME}_test PRIVATE algorithm_template_INCLUDE)
14+
MESSAGE(STATUS "${PROJECT_NAME}_${elementName} from ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp")
15+
add_test(${PROJECT_NAME}_CTEST ${PROJECT_NAME}_test)
16+
set(CMAKE_CXX_STANDARD 11)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# lab_06_A — Different Substrings
2+
3+
## Description
4+
5+
Given a string , you are required to calculate how many different substrings it has.
6+
7+
Here we define two strings are different if and only if they have different length or have at least one position where they have different characters
8+
9+
## Input
10+
11+
One line, indicating the string \(S\) \((1\leq |S|\leq 10^2)\)
12+
13+
## Output
14+
15+
One integer, indicating the answer.
16+
17+
## Sample Input
18+
19+
```log
20+
aab
21+
```
22+
23+
## Sample Output
24+
25+
```log
26+
5
27+
```
28+
29+
## HINT
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
// SPDX-FileCopyrightText: 2020-2025 nanoseeds
3+
#include <tuple>
4+
#include <vector>
5+
#include <iostream>
6+
#include <set>
7+
8+
#ifndef ALGORITHM_TEST_MACRO
9+
#pragma GCC optimize(3, "Ofast", "inline", "no-stack-protector", "unroll-loops")
10+
#pragma GCC optimize("inline-small-functions")
11+
#pragma GCC optimize("-finline-small-functions")
12+
#pragma GCC target("mmx")
13+
#else
14+
namespace lab_06_A{
15+
#endif
16+
using std::tie;
17+
using std::cin;
18+
using std::cout;
19+
using std::tuple;
20+
using std::vector;
21+
using std::set;
22+
static constexpr const char end{'\n'};
23+
24+
using num_t = int32_t;
25+
using input_type = std::string;
26+
using output_type = num_t;
27+
28+
inline input_type read();
29+
30+
output_type cal(const input_type& data);
31+
32+
void output(const output_type &data);
33+
34+
int main() {
35+
const auto input_data = read();
36+
const auto output_data = cal(input_data);
37+
output(output_data);
38+
return 0;
39+
}
40+
41+
inline input_type read() {
42+
input_type a;
43+
std::cin >> a;
44+
return a;
45+
}
46+
47+
output_type cal(const input_type& data) {
48+
const int32_t n = static_cast<int32_t>(data.size());
49+
std::set<std::string> subs;
50+
for (int32_t i = 0; i < n; ++i) {
51+
for (int32_t len = 1; i + len <= n; ++len) {
52+
subs.insert(data.substr(i, len));
53+
}
54+
}
55+
return static_cast<output_type>(subs.size());
56+
}
57+
58+
void output(const output_type &data) {
59+
std::cout << data << end;
60+
}
61+
62+
static const auto faster_streams = [] {
63+
srand(time(nullptr));
64+
// use time to init the random seed
65+
std::ios::sync_with_stdio(false);
66+
std::istream::sync_with_stdio(false);
67+
std::ostream::sync_with_stdio(false);
68+
std::cin.tie(nullptr);
69+
std::cout.tie(nullptr);
70+
// 关闭c++风格输入输出 , 与C风格输入输出的同步,提高性能.
71+
return 0;
72+
}();
73+
74+
#ifdef ALGORITHM_TEST_MACRO
75+
}
76+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aab
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5

0 commit comments

Comments
 (0)