Skip to content

Commit 8fb8010

Browse files
committed
chore: Change clang-format style
1 parent def3ccc commit 8fb8010

File tree

7 files changed

+140
-46
lines changed

7 files changed

+140
-46
lines changed

judger/uoj_judger/.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ Cpp11BracedListStyle: true
4040

4141
# 将 public/private/protected 访问修饰符向左缩进
4242
AccessModifierOffset: -4
43+
44+
# 禁止短非空语句放在同一行
45+
AllowShortBlocksOnASingleLine: Empty
46+
AllowShortFunctionsOnASingleLine: Empty

judger/uoj_judger/include/uoj_judger.h

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,10 @@ class score_t {
368368
SCORE_OP(-=)
369369
#undef SCORE_OP
370370

371-
#define SCORE_OP(x) \
372-
inline score_t operator x() { return x __scr; }
371+
#define SCORE_OP(x) \
372+
inline score_t operator x() { \
373+
return x __scr; \
374+
}
373375
SCORE_OP(-)
374376
SCORE_OP(+)
375377
#undef SCORE_OP
@@ -383,9 +385,13 @@ class score_t {
383385
}
384386
}
385387

386-
explicit inline operator int() const { return (int)round(__scr); }
388+
explicit inline operator int() const {
389+
return (int)round(__scr);
390+
}
387391

388-
explicit inline operator double() const { return __scr; }
392+
explicit inline operator double() const {
393+
return __scr;
394+
}
389395

390396
friend inline ostream &operator<<(ostream &out, const score_t &scr) {
391397
auto default_prec = out.precision();
@@ -529,7 +535,9 @@ struct SubtaskInfo {
529535
vector<PointInfo> points;
530536

531537
SubtaskInfo() = default;
532-
SubtaskInfo(const SubtaskMetaInfo &meta) : meta(meta) { scr = meta.full_score; }
538+
SubtaskInfo(const SubtaskMetaInfo &meta) : meta(meta) {
539+
scr = meta.full_score;
540+
}
533541

534542
inline void update_stats(int _ust, int _usm) {
535543
if (_ust >= 0) {
@@ -754,7 +762,9 @@ string conf_str(const string &key, const string &val) {
754762
}
755763
return config[key];
756764
}
757-
string conf_str(const string &key) { return conf_str(key, ""); }
765+
string conf_str(const string &key) {
766+
return conf_str(key, "");
767+
}
758768
int conf_int(const string &key, const int &val) {
759769
if (config.count(key) == 0) {
760770
return val;
@@ -769,7 +779,9 @@ int conf_int(const string &key, int num, const int &val) {
769779
}
770780
return atoi(config[sout.str()].c_str());
771781
}
772-
int conf_int(const string &key) { return conf_int(key, 0); }
782+
int conf_int(const string &key) {
783+
return conf_int(key, 0);
784+
}
773785
double conf_double(const string &key, const double &val) {
774786
if (config.count(key) == 0) {
775787
return val;
@@ -784,7 +796,9 @@ double conf_double(const string &key, int num, const double &val) {
784796
}
785797
return stod(config[sout.str()]);
786798
}
787-
double conf_double(const string &key) { return conf_double(key, 0); }
799+
double conf_double(const string &key) {
800+
return conf_double(key, 0);
801+
}
788802
score_t conf_score(const string &key, const score_t &val) {
789803
return score_t(conf_double(key, double(val))).rounded_score();
790804
}
@@ -799,8 +813,12 @@ string conf_file_name_with_num(const string &s, int num) {
799813
name << conf_str(s + "_pre", s) << std::abs(num) << "." << conf_str(s + "_suf", "txt");
800814
return name.str();
801815
}
802-
string conf_input_file_name(int num) { return conf_file_name_with_num("input", num); }
803-
string conf_output_file_name(int num) { return conf_file_name_with_num("output", num); }
816+
string conf_input_file_name(int num) {
817+
return conf_file_name_with_num("input", num);
818+
}
819+
string conf_output_file_name(int num) {
820+
return conf_file_name_with_num("output", num);
821+
}
804822
runp::limits_t conf_run_limit(string pre, const int &num, const runp::limits_t &val) {
805823
if (!pre.empty()) {
806824
pre += "_";
@@ -847,12 +865,16 @@ SubtaskMetaInfo conf_subtask_meta_info(string pre, const int &num) {
847865
}
848866
return meta;
849867
}
850-
SubtaskMetaInfo conf_subtask_meta_info(const int &num) { return conf_subtask_meta_info("", num); }
868+
SubtaskMetaInfo conf_subtask_meta_info(const int &num) {
869+
return conf_subtask_meta_info("", num);
870+
}
851871
void conf_add(const string &key, const string &val) {
852872
if (config.count(key)) return;
853873
config[key] = val;
854874
}
855-
bool conf_has(const string &key) { return config.count(key) != 0; }
875+
bool conf_has(const string &key) {
876+
return config.count(key) != 0;
877+
}
856878
bool conf_is(const string &key, const string &val) {
857879
if (config.count(key) == 0) return false;
858880
return config[key] == val;
@@ -862,8 +884,12 @@ bool conf_is(const string &key, const string &val) {
862884

863885
/*====================== info print =================== */
864886

865-
inline string info_str(int id) { return runp::rstype_str((runp::RS_TYPE)id); }
866-
inline string info_str(const RunResult &p) { return info_str(p.type); }
887+
inline string info_str(int id) {
888+
return runp::rstype_str((runp::RS_TYPE)id);
889+
}
890+
inline string info_str(const RunResult &p) {
891+
return info_str(p.type);
892+
}
867893

868894
void add_point_info(const PointInfo &info, bool update_tot_score = true) {
869895
if (info.num >= 0) {
@@ -1107,7 +1133,9 @@ RunResult run_program(const runp::config &rpc) {
11071133
}
11081134

11091135
// @return interaction return value
1110-
int run_interaction(const RunInteractionConfig &ric) { return runp::interaction::run(ric); }
1136+
int run_interaction(const RunInteractionConfig &ric) {
1137+
return runp::interaction::run(ric);
1138+
}
11111139

11121140
RunResult run_program(const char *run_program_result_file_name, const char *input_file_name,
11131141
const char *output_file_name, const char *error_file_name,

judger/uoj_judger/include/uoj_judger_v2.h

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,9 @@ class jgf_error : exception {
503503
}
504504
}
505505

506-
virtual const char *what() const noexcept override { return this->info.c_str(); }
506+
virtual const char *what() const noexcept override {
507+
return this->info.c_str();
508+
}
507509
};
508510

509511
/*==================== parameter End ================== */
@@ -548,7 +550,9 @@ string conf_str(const string &key, const string &val) {
548550
}
549551
return uconfig[key];
550552
}
551-
string conf_str(const string &key) { return conf_str(key, ""); }
553+
string conf_str(const string &key) {
554+
return conf_str(key, "");
555+
}
552556
int conf_int(const string &key, const int &val) {
553557
if (uconfig.count(key) == 0) {
554558
return val;
@@ -563,7 +567,9 @@ int conf_int(const string &key, int num, const int &val) {
563567
}
564568
return atoi(uconfig[sout.str()].c_str());
565569
}
566-
int conf_int(const string &key) { return conf_int(key, 0); }
570+
int conf_int(const string &key) {
571+
return conf_int(key, 0);
572+
}
567573
double conf_double(const string &key, const double &val) {
568574
if (uconfig.count(key) == 0) {
569575
return val;
@@ -578,7 +584,9 @@ double conf_double(const string &key, int num, const double &val) {
578584
}
579585
return stod(uconfig[sout.str()]);
580586
}
581-
double conf_double(const string &key) { return conf_double(key, 0); }
587+
double conf_double(const string &key) {
588+
return conf_double(key, 0);
589+
}
582590
string conf_file_name_with_num(string s, int num) {
583591
ostringstream name;
584592
if (num < 0) {
@@ -587,8 +595,12 @@ string conf_file_name_with_num(string s, int num) {
587595
name << conf_str(s + "_pre", s) << abs(num) << "." << conf_str(s + "_suf", "txt");
588596
return name.str();
589597
}
590-
string conf_input_file_name(int num) { return conf_file_name_with_num("input", num); }
591-
string conf_output_file_name(int num) { return conf_file_name_with_num("output", num); }
598+
string conf_input_file_name(int num) {
599+
return conf_file_name_with_num("input", num);
600+
}
601+
string conf_output_file_name(int num) {
602+
return conf_file_name_with_num("output", num);
603+
}
592604
runp::limits_t conf_run_limit(string pre, const int &num, const runp::limits_t &val) {
593605
if (!pre.empty()) {
594606
pre += "_";
@@ -610,7 +622,9 @@ void conf_add(const string &key, const string &val) {
610622
}
611623
uconfig[key] = val;
612624
}
613-
bool conf_has(const string &key) { return uconfig.count(key); }
625+
bool conf_has(const string &key) {
626+
return uconfig.count(key);
627+
}
614628
bool conf_is(const string &key, const string &val) {
615629
return uconfig.count(key) && uconfig[key] == val;
616630
}
@@ -1303,7 +1317,9 @@ bool TestPoint::add_info_block(const string &fkey) {
13031317
return true;
13041318
}
13051319

1306-
bool TestPoint::check() { return po.info.empty() || po.scr == 100; }
1320+
bool TestPoint::check() {
1321+
return po.info.empty() || po.scr == 100;
1322+
}
13071323

13081324
bool TestPoint::prepare_io() {
13091325
try {
@@ -1899,7 +1915,9 @@ CustomTestInfo ordinary_custom_test(const string &name) {
18991915
}
19001916
*/
19011917

1902-
int scale_score(int scr100, int full) { return scr100 * full / 100; }
1918+
int scale_score(int scr100, int full) {
1919+
return scr100 * full / 100;
1920+
}
19031921

19041922
/*====================== test End ================== */
19051923

@@ -2048,17 +2066,29 @@ class Judger {
20482066
}
20492067

20502068
public:
2051-
virtual int n_tests() { return conf_int("n_tests", 10); }
2069+
virtual int n_tests() {
2070+
return conf_int("n_tests", 10);
2071+
}
20522072

2053-
virtual int n_ex_tests() { return conf_int("n_ex_tests", 0); }
2073+
virtual int n_ex_tests() {
2074+
return conf_int("n_ex_tests", 0);
2075+
}
20542076

2055-
virtual int n_sample_tests() { return conf_int("n_sample_tests", 0); }
2077+
virtual int n_sample_tests() {
2078+
return conf_int("n_sample_tests", 0);
2079+
}
20562080

2057-
virtual int sample_test_point_score(int num) { return 100 / this->n_sample_tests(); }
2081+
virtual int sample_test_point_score(int num) {
2082+
return 100 / this->n_sample_tests();
2083+
}
20582084

2059-
virtual bool is_hack_enabled() { return true; }
2085+
virtual bool is_hack_enabled() {
2086+
return true;
2087+
}
20602088

2061-
virtual bool is_custom_test_enabled() { return true; }
2089+
virtual bool is_custom_test_enabled() {
2090+
return true;
2091+
}
20622092

20632093
virtual void ordinary_test() {
20642094
int n = conf_int("n_tests", 10);
@@ -2336,17 +2366,25 @@ class SubmitAnswerJudger : public Judger {
23362366
}
23372367

23382368
public:
2339-
virtual int n_ex_tests() override { return 0; }
2369+
virtual int n_ex_tests() override {
2370+
return 0;
2371+
}
23402372

2341-
virtual int n_sample_tests() override { return this->n_tests(); }
2373+
virtual int n_sample_tests() override {
2374+
return this->n_tests();
2375+
}
23422376

23432377
virtual int sample_test_point_score(int num) override {
23442378
return conf_int("point_score", num, 100 / this->n_sample_tests());
23452379
}
23462380

2347-
virtual bool is_hack_enabled() override { return false; }
2381+
virtual bool is_hack_enabled() override {
2382+
return false;
2383+
}
23482384

2349-
virtual bool is_custom_test_enabled() override { return false; }
2385+
virtual bool is_custom_test_enabled() override {
2386+
return false;
2387+
}
23502388
};
23512389

23522390
/*====================== judger end ================== */

judger/uoj_judger/include/uoj_run.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#define UOJ_JDK "/usr/lib/jvm/java-21-openjdk-amd64"
2424
#define UOJ_JAVA_VERSION "21"
2525

26-
std::string escapeshellarg(int arg) { return std::to_string(arg); }
26+
std::string escapeshellarg(int arg) {
27+
return std::to_string(arg);
28+
}
2729
std::string escapeshellarg(double arg) {
2830
std::ostringstream sout;
2931
sout << std::setprecision(15) << arg;
@@ -462,5 +464,7 @@ struct config {
462464
/*
463465
* @return interaction return value
464466
**/
465-
int run(const config &ric) { return execute(ric.get_cmd().c_str()); }
467+
int run(const config &ric) {
468+
return execute(ric.get_cmd().c_str());
469+
}
466470
} // namespace runp::interaction

judger/uoj_judger/include/uoj_secure.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ using namespace std;
2323
struct sha256_t {
2424
u8 sum[32];
2525

26-
string to_str() { return string((char *)sum, 32); }
26+
string to_str() {
27+
return string((char *)sum, 32);
28+
}
2729
};
2830

29-
inline u32 uoj_sha2_rotr(u32 x, int n) { return x >> n | x << (32 - n); }
31+
inline u32 uoj_sha2_rotr(u32 x, int n) {
32+
return x >> n | x << (32 - n);
33+
}
3034

3135
void uoj_sha256_chunk(u8 *chunk, u32 *hs) {
3236
static const u32 k[] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
@@ -113,7 +117,9 @@ sha256_t uoj_sha256(int n, u8 *m) {
113117
}
114118
return sum;
115119
}
116-
sha256_t uoj_sha256(const string &m) { return uoj_sha256((int)m.length(), (u8 *)m.data()); }
120+
sha256_t uoj_sha256(const string &m) {
121+
return uoj_sha256((int)m.length(), (u8 *)m.data());
122+
}
117123

118124
sha256_t uoj_hmac(const string &k, const string &m) {
119125
string ki = k, ko = k;
@@ -156,7 +162,9 @@ class uoj_mt_rand_engine {
156162
}
157163

158164
public:
159-
uoj_mt_rand_engine(u64 seed) { init(seed); }
165+
uoj_mt_rand_engine(u64 seed) {
166+
init(seed);
167+
}
160168
uoj_mt_rand_engine(const string &s) {
161169
sha256_t sum = uoj_sha256(s);
162170

@@ -198,7 +206,9 @@ class uoj_cipher {
198206
uoj_cipher() {}
199207
uoj_cipher(const string &_key) : key(_key) {}
200208

201-
void set_key(const string &_key) { key = _key; }
209+
void set_key(const string &_key) {
210+
key = _key;
211+
}
202212

203213
void encrypt(string &m) {
204214
uoj_mt_rand_engine rnd(key);
@@ -292,7 +302,9 @@ class uoj_secure_io {
292302
in.str(input_m);
293303
}
294304

295-
string input() { return input_m; }
305+
string input() {
306+
return input_m;
307+
}
296308

297309
UOJ_NORETURN void end(string m) {
298310
memcpy(stdout, &true_outf, sizeof(FILE));
@@ -312,6 +324,8 @@ class uoj_secure_io {
312324
exit(0);
313325
}
314326

315-
UOJ_NORETURN void end() { end(""); }
327+
UOJ_NORETURN void end() {
328+
end("");
329+
}
316330
};
317331
} // namespace

0 commit comments

Comments
 (0)