Skip to content

Commit 2f18e95

Browse files
committed
fix: CRLF in testcases
1 parent 852ff16 commit 2f18e95

File tree

6 files changed

+136
-25
lines changed

6 files changed

+136
-25
lines changed

14500.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#include <bits/stdc++.h>
2+
3+
#define debug if constexpr (local) std::cout
4+
#define endl '\n'
5+
#define fi first
6+
#define se second
7+
8+
#ifdef LOCAL
9+
constexpr bool local = true;
10+
#else
11+
constexpr bool local = false;
12+
#endif
13+
14+
typedef long long ll;
15+
typedef unsigned long long ull;
16+
17+
using namespace std;
18+
19+
/* - GLOBAL VARIABLES ---------------------------- */
20+
int paper[500][500], N, M;
21+
vector<vector<pair<int, int>>> I = {
22+
{{0, 0}, {0, 1}, {0, 2}, {0, 3}},
23+
{{0, 0}, {1, 0}, {2, 0}, {3, 0}}
24+
};
25+
vector<vector<pair<int, int>>> L1 = {
26+
{{0, 0}, {1, 0}, {2, 0}, {2, 1}}, // 0
27+
{{0, 0}, {0, 1}, {0, 2}, {1, 0}}, // 90
28+
{{0, 0}, {0, 1}, {1, 0}, {2, 0}}, // 180
29+
{{1, 0}, {1, 1}, {1, 2}, {0, 2}} // 270
30+
};
31+
32+
vector<vector<pair<int, int>>> L2 = {
33+
{{0, 0}, {1, 0}, {1, 1}, {1, 2}}, // 0
34+
{{0, 0}, {0, 1}, {1, 1}, {2, 1}}, // 90
35+
{{0, 0}, {0, 1}, {0, 2}, {1, 2}}, // 180
36+
{{2, 0}, {2, 1}, {1, 1}, {0, 1}} // 270
37+
};
38+
39+
vector<vector<pair<int, int>>> O = {
40+
{{0, 0}, {1, 0}, {1, 1}, {0, 1}} // 0
41+
};
42+
vector<vector<pair<int, int>>> S1 = {
43+
{{1, 0}, {1, 1}, {0, 1}, {0, 2}}, // 0
44+
{{0, 0}, {1, 0}, {1, 1}, {2, 1}} // 0
45+
};
46+
47+
vector<vector<pair<int, int>>> S2 = {
48+
{{1, 0}, {2, 0}, {0, 1}, {1, 1}}, // 0
49+
{{0, 0}, {0, 1}, {1, 1}, {1, 2}} // 0
50+
};
51+
vector<vector<pair<int, int>>> T = {
52+
{{0, 0}, {0, 1}, {0, 2}, {1, 1}}, // 0
53+
{{0, 1}, {1, 1}, {2, 1}, {1, 0}}, // 0
54+
{{1, 0}, {1, 1}, {1, 2}, {0, 1}}, // 0
55+
{{0, 0}, {1, 0}, {2, 0}, {1, 1}}, // 0
56+
};
57+
/* ----------------------------------------------- */
58+
/* - FUNCTIONS ----------------------------------- */
59+
bool is_out_of_index(int ny, int nx) {
60+
if(ny < 0 || N <= ny || nx < 0 || M <= nx)
61+
return true;
62+
63+
return false;
64+
}
65+
int get_max_sum(vector<vector<pair<int, int>>> &filter) {
66+
int ret = 0;
67+
for(int i = 0; i < filter.size(); i++) {
68+
for(int y = 0; y < N; ++y) {
69+
for(int x = 0; x < M; ++x) {
70+
int sum = 0;
71+
for(int j = 0; j < filter[i].size(); ++j) {
72+
int ny = y + filter[i][j].fi;
73+
int nx = x + filter[i][j].se;
74+
75+
if(is_out_of_index(ny, nx)) {
76+
sum = 0;
77+
break;
78+
}
79+
sum += paper[ny][nx];
80+
}
81+
82+
ret = max(sum, ret);
83+
}
84+
}
85+
}
86+
return ret;
87+
}
88+
/* ----------------------------------------------- */
89+
int main() {
90+
ios_base::sync_with_stdio(false);
91+
cin.tie(0); cout.tie(0);
92+
if constexpr (local)
93+
(void)!freopen("input.txt", "r", stdin);
94+
cin >> N >> M;
95+
for(int i = 0; i < N; ++i) {
96+
for(int j = 0; j < M; ++j) {
97+
cin >> paper[i][j];
98+
}
99+
}
100+
int answer = 0;
101+
102+
answer = max(answer, get_max_sum(I));
103+
answer = max(answer, get_max_sum(L1));
104+
answer = max(answer, get_max_sum(L2));
105+
answer = max(answer, get_max_sum(O));
106+
answer = max(answer, get_max_sum(S1));
107+
answer = max(answer, get_max_sum(S2));
108+
answer = max(answer, get_max_sum(T));
109+
110+
cout << answer << endl;
111+
112+
return 0;
113+
}

boj/commands/init/init_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def execute(self, args, config: Config):
2222
problem_page = BojProblemPage(html=response.text)
2323

2424
testcases = problem_page.extract_testcases()
25-
yaml_testcases = util.testcases_to_yaml(testcases)
25+
yaml_testcases = util.testcases_to_yaml_content(testcases)
2626

2727
util.write_file(constant.testcase_file_path(), yaml_testcases, "w")
2828
console.print("Testcases have been created.")

boj/core/constant.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def solved_ac_search_problem_url():
5353
return f"{solved_ac_search_url()}/problem"
5454

5555

56-
def salt():
57-
return "6843f2dc-24fa-11e9-b84a-f8633f2431a4"
58-
59-
6056
def default_headers():
6157
return {
6258
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) "

boj/core/data.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ def __init__(self, data_in, data_out):
2424
def __repr__(self):
2525
return "Testcase {" + str(self.data_in) + ", " + self.data_out + "}"
2626

27-
def to_dict(self):
28-
return {"input": self.data_in, "output": self.data_out}
29-
3027

3128
class Credential:
3229
username: str
@@ -44,5 +41,3 @@ def session_cookies_of(self, online_judge_token):
4441
"bojautologin": self.token,
4542
"OnlineJudge": online_judge_token
4643
}
47-
48-

boj/core/util.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,26 @@ def read_testcases() -> list[Testcase]:
104104
]
105105

106106

107-
def testcases_to_yaml(testcases: list[Testcase]):
108-
def str_presenter(dumper, data):
109-
if isinstance(data, str) and data.startswith(constant.salt()):
110-
data = data.replace(constant.salt(), "")
111-
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
107+
def testcases_to_yaml_content(testcases: list[Testcase]):
108+
yaml_content = ""
109+
for testcase in testcases:
110+
yaml_content = yaml_content + "- input: |\n"
112111

113-
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
112+
input_content = ""
113+
for line in testcase.data_in.splitlines():
114+
input_content = input_content + (" "*4) + line + "\n"
114115

115-
yaml.add_representer(str, str_presenter)
116-
yaml.representer.SafeRepresenter.add_representer(str, str_presenter)
116+
yaml_content = yaml_content + input_content
117117

118-
yaml_testcases = yaml.dump([t.to_dict() for t in testcases], indent=2)
119-
return yaml_testcases.replace("- input", "\n- input").lstrip()
118+
yaml_content = yaml_content + (" "*2) + "output: |\n"
119+
output_content = ""
120+
for line in testcase.data_out.splitlines():
121+
output_content = output_content + (" "*4) + line + "\n"
122+
123+
yaml_content = yaml_content + output_content
124+
yaml_content = yaml_content + "\n"
125+
126+
return yaml_content
120127

121128

122129
def read_config_file() -> dict:

boj/pages/problem_page.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ def extract_testcases(self):
1616
inputs = []
1717
outputs = []
1818
for data in sample_data:
19-
text = data.text
19+
text = data.text.strip()
2020

2121
if "input" in str(data.get("id", "")):
2222
text = text.rstrip()
23-
inputs.append(text.rstrip())
23+
inputs.append(text)
2424

2525
if "output" in str(data.get("id", "")):
2626
text = text.rstrip()
27-
outputs.append(text.rstrip())
27+
outputs.append(text)
2828

2929
test_idx = 1
3030
testcases: list[Testcase] = []
3131
for data_in, data_out in zip(inputs, outputs):
3232
testcases.append(
3333
Testcase(
34-
data_in=constant.salt() + data_in + "\n",
35-
data_out=constant.salt() + data_out + "\n",
34+
data_in=data_in,
35+
data_out=data_out
3636
)
3737
)
3838

0 commit comments

Comments
 (0)