diff --git a/Checker/Adapters/UOJJudger.cpp b/Checker/Adapters/UOJJudger.cpp index fd681d9..bba8b0b 100644 --- a/Checker/Adapters/UOJJudger.cpp +++ b/Checker/Adapters/UOJJudger.cpp @@ -59,8 +59,6 @@ static bool readOpt(Option& opt, maxTime * 1000000)); opt.insert("MemoryLimit", maxMem << 10); opt.insert("CompareMode", CompareMode::Text); - opt.insert("TimeSamples", - fs::path("CheckerDir/UOJ-Samples")); return true; } static bool runUOJ(const fs::path& exec) { diff --git a/Checker/CMakeLists.txt b/Checker/CMakeLists.txt index 5ad05ff..051a7fb 100644 --- a/Checker/CMakeLists.txt +++ b/Checker/CMakeLists.txt @@ -22,10 +22,6 @@ endif(NOT HAS_UNZIP) find_program(HAS_PERF perf) find_program(HAS_SYZOJTOOLS syzoj) -set (CHECKER_VERSION_MAJOR 2) -set (CHECKER_VERSION_MINOR 9) -set (CHECKER_VERSION_PATCH 0) - option(BZOJ_JUDGER "bzoj-judger" ON) option(LOJ_JUDGER "loj-judger" ON) option(UOJ_JUDGER "uoj-judger" ON) diff --git a/Checker/Checker.cpp b/Checker/Checker.cpp index 0700ec7..0664d82 100644 --- a/Checker/Checker.cpp +++ b/Checker/Checker.cpp @@ -8,10 +8,10 @@ int main() { std::cout.precision(2); std::cout << std::fixed; - line("Checker " VERSION, '*'); + line("Checker for " CHECKER_PLATFORM " 2.9.1", + '*'); std::cout << "Built at " << __TIME__ << " on " << __DATE__ << std::endl; - platformInfo(); fs::path exec = scanExec(); std::cout << "found program:" << exec << std::endl; autoRun(exec); diff --git a/Checker/CheckerConfig.hpp.in b/Checker/CheckerConfig.hpp.in index f0f24cb..69b83ae 100644 --- a/Checker/CheckerConfig.hpp.in +++ b/Checker/CheckerConfig.hpp.in @@ -1,3 +1,3 @@ -#define VERSION "@CHECKER_VERSION_MAJOR@.@CHECKER_VERSION_MINOR@.@CHECKER_VERSION_PATCH@" +#define CHECKER_PLATFORM "@CMAKE_SYSTEM_NAME@" #cmakedefine USE_SYZOJTOOLS #cmakedefine USE_PERF diff --git a/Checker/Platforms/Linux/PlatformLinux.cpp b/Checker/Platforms/Linux/PlatformLinux.cpp index e10a5fd..e4fbe90 100644 --- a/Checker/Platforms/Linux/PlatformLinux.cpp +++ b/Checker/Platforms/Linux/PlatformLinux.cpp @@ -7,9 +7,6 @@ #include #include #include -void platformInfo() { - system("lsb_release -d"); -} void initPlatform() { struct rlimit limit; getrlimit(RLIMIT_STACK, &limit); diff --git a/Checker/Platforms/Platform.hpp b/Checker/Platforms/Platform.hpp index 2c95fcc..6854776 100644 --- a/Checker/Platforms/Platform.hpp +++ b/Checker/Platforms/Platform.hpp @@ -8,6 +8,5 @@ #include "Linux/PlatformLinux.hpp" #endif void initPlatform(); -void platformInfo(); void reportJudgeError(const RunResult& res); int getConsoleWidth(); diff --git a/Checker/Platforms/Windows/PlatformWindows.cpp b/Checker/Platforms/Windows/PlatformWindows.cpp index cc9d97d..bd00dc0 100644 --- a/Checker/Platforms/Windows/PlatformWindows.cpp +++ b/Checker/Platforms/Windows/PlatformWindows.cpp @@ -61,9 +61,6 @@ void initPlatform() { old | ENABLE_VIRTUAL_TERMINAL_PROCESSING)); setCodePage(65001); } -void platformInfo() { - system("ver"); -} static const std::string& getWinntHeader() { static std::string str = file2Str(readConfig("WinntHeader")); diff --git a/Checker/readme.md b/Checker/readme.md index ee24005..a2c873d 100644 --- a/Checker/readme.md +++ b/Checker/readme.md @@ -128,9 +128,12 @@ AC后询问OJ上的时间并加入samples中,在BZOJ计时方式下skip掉剩 2.8.4(5.14) 修复系统时间超时产生SIGXCPU信号,误判TLE的问题。 -2.9.0(5.15) +2.9.0(5.18) 支持UOJ题目读取与样例数据下载 +2.9.1(5.19) +取消UOJ的TimeSample(样例数据与评测数据不同) + ## TODO List - [x] 跨Windows平台、分离平台实现 diff --git a/OI-Source.code-workspace b/OI-Source.code-workspace index 4ae4283..34140f9 100644 --- a/OI-Source.code-workspace +++ b/OI-Source.code-workspace @@ -87,7 +87,8 @@ "source_location": "cpp", "*.idl": "cpp", "hash_map": "cpp", - "hash_set": "cpp" + "hash_set": "cpp", + "decimal": "cpp" }, "latex-workshop.intellisense.citation.maxfilesizeMB": 128, "latex-workshop.latex.recipes": [ diff --git a/Queue.md b/Queue.md index 288b963..c54fcef 100644 --- a/Queue.md +++ b/Queue.md @@ -86,6 +86,7 @@ # minmax容斥 - [x] LOJ#2542. 「PKUWC2018」随机游走 - [x] LOJ#2127. 「HAOI2015」按位或(做完后作为minmax容斥的例题) +- [ ] UOJ#449 # FFT/NTT/FWT/生成函数 - [x] LOJ#151. 多项式求立方根 - [x] LOJ#2527. 「HAOI2018」染色 diff --git a/Review/Backmatter.tex b/Review/Backmatter.tex index 3239e99..4ca4508 100644 --- a/Review/Backmatter.tex +++ b/Review/Backmatter.tex @@ -319,3 +319,48 @@ \subsection{day2} 就叫我滚回去学文化课了。 混了两年换来这个结果。不仅没得到想要的,还失去了许多。。。这就是人生? +\section{End} +2019年5月20日 + +最后一次比赛后我就再也碰不了电子设备了,所以这里提前做个收尾。 + +THUSC2019应该是我OI生涯中的最后一站吧。我也大概知道了结局,否则也不会花一个月的时间搞 +THUAC,甚至抽时间刷电影,这两个是我一直想做但忍着不做的事。 + +我没能达到自己的要求,既不能留住她,也不能让自己走出失恋的阴影,从而丧失刷题的动力。 + +我还有一堆的TODO没有做完,如果我能撑到高中毕业而没有崩溃的话,我会抽时间完成它的。但是不 +再加入新的东西。如果有学弟愿意接手这个烂摊子,可以发Pull Request给我。 + +至于开班造学弟的事情,由于我可能上不了很好的大学,会成为反面教材,并且加上近年来moe对 +竞赛方面自主招生的打压,应该不会有家长送人来,学校也不会配合的。我能留给学弟的,只有这 +本笔记,附赠一个Checker。 + +送给学弟们的忠告: +\begin{itemize} + \item 适当地娱乐,要注意调整比例。我当时靠着鼓捣CG还能保持0娱乐,离开它后整个人 + 就变得毫无生气,离开她后就开始颓废。 + \item 尽量组团学习,同等级OIer之间的交流可以大量节约时间,而且不会感到孤独。 + \item 我在笔记中标记的坑,一定要记住。这是我用时间与分数换来的。 + \item 多训练思维。在掌握笔记中的知识后,你们能做的只有裸题而已。要思考如何将考点隐藏, + 如何转化。 + \item 多出题。上面一条我也做不到,因为我能接触到的题目少。如果你们是组团学习的,可以考虑 + 互相出题,互相Hack,这同样是一种训练。多Hack可以熟悉出题人可以怎样卡掉某个算法。 + \item 多打比赛。平时训练和比赛时的心理与策略是十分不同的。缺少比赛也是我的不足。 + \item 所以说,只要人数多,你们就可以自己出题,举办校赛,赛后hack,这样的训练效果比我自己 + 一个人刷题好得多。 + \item 同样重视数学和编程方面的训练。虽然OI侧重于算法设计,但是数学功底好就可以快速 + 推导式子,提高对语言的掌握程度可以减少bug。 + \item 如果有事找我,请确保你的C++代码大括号不换行。其它的代码风格我可以兼容,但是大括号 + 免谈。 +\end{itemize} + +希望将来我校有人能完成我未能完成的梦想,最好能挑大梁,培养更多的学弟学妹。 + +希望这本笔记对你们有一些帮助。 + +\begin{figure} + \centering + \includegraphics[width=0.8\textwidth,clip]{mypic.jpg} + \caption{这应该是本笔记唯一一张图了} +\end{figure} diff --git a/Review/Main.tex b/Review/Main.tex index 9a0ee9c..dc859d5 100644 --- a/Review/Main.tex +++ b/Review/Main.tex @@ -30,6 +30,7 @@ \dominitoc[n] \usepackage{shorttoc} %Feature +\usepackage{graphicx} \usepackage{xcolor} \usepackage{CJKfntef} \newfontfamily\CodeFont{Consolas} diff --git a/Review/Math/Inversion.tex b/Review/Math/Inversion.tex index 29f1698..4d8dabd 100644 --- a/Review/Math/Inversion.tex +++ b/Review/Math/Inversion.tex @@ -117,7 +117,7 @@ \subsubsection{期望形式} \paragraph{例题~「HAOI2015」按位或} 记$max(S)$为状态S中最晚出现的1的出现的期望时间,$min(S)$为状态S中最早出现 -的1的出现的期望时间。$min(S)$很容易求得其表达式,考虑与$S$的交不为空集的$T$,表达式为 +的1的出现期望时间。$min(S)$很容易求得其表达式,考虑与$S$的交不为空集的$T$,表达式为 $min(S)=\frac{1}{\displaystyle \sum_{T\cap S \neq \emptyset}{P_T}}$(根据 伯努利试验中几何分布的期望求得,参见第~\ref{Bernoulli}节)。 这个式子仍然不好求,可以考虑补集转换,即考虑$T$与$S$的交为空集的情况。这个条件蕴含了 diff --git a/Review/Optmize/LP.tex b/Review/Optmize/LP.tex index dd3cf24..73056f4 100644 --- a/Review/Optmize/LP.tex +++ b/Review/Optmize/LP.tex @@ -198,6 +198,9 @@ \subsubsection{初始化init} \subsubsection{算法实现(UOJ179)} 为了过掉UOJ的Extra Test,这里使用了两种初始化方法的混合(然而还是过不去, 只能指望Mehrotra predictor–corrector method了)。 + +Update:事实上应该是浮点数精度不够。 + \lstinputlisting{Source/Templates/SimplexSLP.cpp} \subsubsection{稀疏矩阵优化} diff --git a/Review/mypic.jpg b/Review/mypic.jpg new file mode 100644 index 0000000..f5e372f Binary files /dev/null and b/Review/mypic.jpg differ diff --git a/Source/Greed/UOJ455.cpp b/Source/Greed/UOJ455WA.cpp similarity index 100% rename from Source/Greed/UOJ455.cpp rename to Source/Greed/UOJ455WA.cpp diff --git a/Source/Network Flows/POJ2175.cpp b/Source/Network Flows/POJ2175.cpp new file mode 100644 index 0000000..d544aa9 --- /dev/null +++ b/Source/Network Flows/POJ2175.cpp @@ -0,0 +1,11 @@ +#include +const int size = 105; +struct Point { + int x, y, z; +} A[size], B[size]; +int main() { + int n, m; + scanf("%d%d", &n, &m); + + return 0; +} diff --git a/Templates/Simplex.cpp b/Templates/UOJ179-Simplex.cpp similarity index 56% rename from Templates/Simplex.cpp rename to Templates/UOJ179-Simplex.cpp index 4ebeacd..63fac7e 100644 --- a/Templates/Simplex.cpp +++ b/Templates/UOJ179-Simplex.cpp @@ -1,49 +1,46 @@ #include #include #include -int getRandom() { - static int seed = 2354; - return seed = seed * 48271LL % 2147483647; +typedef float FT __attribute__((mode(TF))); +const FT epsA = 1e-10, epsB = 1e-20, epsC = 1e-30, + zero = 0, one = 1; +FT mabs(FT val) { + return val >= zero ? val : -val; } -typedef long double FT; -const FT eps = 1e-10; const int size = 25; FT A[size][size]; -int id[size * 2], n, m; +int idn[size], idm[size], n, m; void pivot(int l, int e) { - std::swap(id[n + l], id[e]); + std::swap(idm[l], idn[e]); FT fac = A[l][e]; - A[l][e] = 1.0; + A[l][e] = one; for(int i = 0; i <= n; ++i) A[l][i] /= fac; for(int i = 0; i <= m; ++i) if(i != l) { FT k = A[i][e]; - A[i][e] = 0.0; + A[i][e] = zero; for(int j = 0; j <= n; ++j) A[i][j] -= k * A[l][j]; } } -int q[size]; bool init() { + idm[0] = idn[0] = 1 << 30; while(true) { - int qcnt = 0; + int l = 0; for(int i = 1; i <= m; ++i) - if(A[i][0] < -eps) - q[qcnt++] = i; - if(qcnt == 0) - break; - int l = q[getRandom() % qcnt]; - qcnt = 0; + if(A[i][0] < -epsA && idm[i] < idm[l]) + l = i; + if(l == 0) + return true; + int e = 0; for(int i = 1; i <= n; ++i) - if(A[l][i] < -eps) - q[qcnt++] = i; - if(qcnt == 0) + if(A[l][i] < -epsA && idn[i] < idn[e]) + e = i; + if(e == 0) return false; - int e = q[getRandom() % qcnt]; pivot(l, e); } - return true; } bool simplex() { if(!init()) { @@ -53,21 +50,19 @@ bool simplex() { while(true) { int e = 0; for(int i = 1; i <= n; ++i) - if(A[0][i] > eps) { + if(A[0][i] > epsB && idn[i] < idn[e]) e = i; - break; - } if(e == 0) break; - FT minv = 1e20; + FT minv = 1e200; int l = 0; for(int i = 1; i <= m; ++i) - if(A[i][e] > eps) { + if(A[i][e] > epsB) { FT val = A[i][0] / A[i][e]; - if(val < minv) { - minv = val; - l = i; - } + if(l == 0 || val < minv || + (mabs(val - minv) < epsC && + idm[i] < idm[l])) + minv = val, l = i; } if(l == 0) { std::cout << "Unbounded" << std::endl; @@ -77,7 +72,20 @@ bool simplex() { } return true; } -FT ans[size]; +FT ans[size * 2]; +typedef long long Int64; +std::istream& operator>>(std::istream& in, FT& val) { + Int64 tmp; + in >> tmp; + val = tmp; + // if(static_cast(val) != tmp) + // throw; + return in; +} +typedef long double IOFT; +std::ostream& operator<<(std::ostream& out, FT val) { + return out << static_cast(val); +} int main() { int t; std::cin >> n >> m >> t; @@ -89,14 +97,16 @@ int main() { std::cin >> A[i][0]; } for(int i = 1; i <= n; ++i) - id[i] = i; + idn[i] = i; + for(int i = 1; i <= m; ++i) + idm[i] = n + i; std::cout.precision(14); if(simplex()) { std::cout << std::fixed << -A[0][0] << std::endl; if(t) { for(int i = 1; i <= m; ++i) - ans[id[n + i]] = A[i][0]; + ans[idm[i]] = A[i][0]; for(int i = 1; i <= n; ++i) std::cout << std::fixed << ans[i] << ' '; diff --git a/Templates/UOJ179.py b/Templates/UOJ179.py new file mode 100644 index 0000000..681cda9 --- /dev/null +++ b/Templates/UOJ179.py @@ -0,0 +1,125 @@ +from decimal import * + +epsA = Decimal() +epsB = Decimal() +epsC = Decimal() +A = [[]] +idn = [] +idm = [] +n = 0 +m = 0 + + +def pivot(l, e): + idm[l], idn[e] = idn[e], idm[l] + fac = A[l][e] + A[l][e] = Decimal(1) + que = [] + for i in range(n+1): + A[l][i] /= fac + if A[l][i] < -epsC or A[l][i] > epsC: + que.append(i) + for i in range(m+1): + if i != l: + k = A[i][e] + A[i][e] = Decimal(0) + if -epsC < k and k < epsC: + continue + for j in que: + A[i][j] -= k * A[l][j] + + +def init(): + while True: + l = -1 + for i in range(m): + if A[i][n] < -epsA and idm[i] < idm[l]: + l = i + if l == -1: + return True + e = -1 + for i in range(n): + if A[l][i] < -epsA and idn[i] < idn[e]: + e = i + if e == -1: + return False + pivot(l, e) + + +def simplex(): + if not init(): + print("Infeasible") + return False + + while True: + e = -1 + for i in range(n): + if A[m][i] > epsB and idn[i] < idn[e]: + e = i + if e == -1: + return True + minv = Decimal(0) + l = -1 + for i in range(m): + if A[i][e] > epsB: + val = A[i][n] / A[i][e] + if (l == -1 or val < minv + or (Decimal.copy_abs(val - minv) < epsC + and idm[i] < idm[l])): + minv = val + l = i + if l == -1: + print("Unbounded") + return False + pivot(l, e) + + +def toString(val): + return Decimal(val).quantize(Decimal('0.00000000')) + + +def mainImpl(): + getcontext().prec = 80 + + global epsA + epsA = Decimal.from_float(1e-20) + global epsB + epsB = Decimal.from_float(1e-30) + global epsC + epsC = Decimal.from_float(1e-40) + + global n + global m + n, m, t = map(int, input().split()) + + tmp = [Decimal(i) for i in input().split()] + [0] + + global A + A = [[] for i in range(m)] + for i in range(m): + A[i] = [Decimal(i) for i in input().split()] + A.append(tmp) + + inf = 1 << 30 + global idn + idn = [i for i in range(n)]+[inf] + global idm + idm = [n+i for i in range(m)]+[inf] + + if simplex(): + print(toString(-A[m][n])) + + if t == 1: + ans = [Decimal('0.0') for i in range(n+m+5)] + for i in range(m): + ans[idm[i]] = A[i][n] + for i in range(n): + print(toString(ans[i]), end=' ') + print() + + +if __name__ == '__main__': + try: + mainImpl() + except Exception as err: + print("Exception:{0}".format(err))