aboutsummaryrefslogtreecommitdiff
path: root/algorithm-contest-2/gen.ps1
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-25 17:16:31 +0800
committercrupest <crupest@outlook.com>2020-10-25 17:17:13 +0800
commit1e05f756960c0b0c7fbd5acc11e5c0ae29134dcc (patch)
tree0d04f01fb53f42c64236f804f0961ed353930b22 /algorithm-contest-2/gen.ps1
parent17efe0b0bc81ac70418c23af7aec620d8c1f858d (diff)
downloadlife-1e05f756960c0b0c7fbd5acc11e5c0ae29134dcc.tar.gz
life-1e05f756960c0b0c7fbd5acc11e5c0ae29134dcc.tar.bz2
life-1e05f756960c0b0c7fbd5acc11e5c0ae29134dcc.zip
Add algorithm contest 2.
Diffstat (limited to 'algorithm-contest-2/gen.ps1')
-rw-r--r--algorithm-contest-2/gen.ps139
1 files changed, 39 insertions, 0 deletions
diff --git a/algorithm-contest-2/gen.ps1 b/algorithm-contest-2/gen.ps1
new file mode 100644
index 0000000..60b88b2
--- /dev/null
+++ b/algorithm-contest-2/gen.ps1
@@ -0,0 +1,39 @@
+Push-Location solution
+
+foreach ($problem in 1..5) {
+ clang-cl "$problem.cpp" /O2 "-fsanitize=address,undefined"
+}
+
+Pop-Location
+
+Remove-Item -Recurse output
+
+mkdir .\output
+
+$time_output = @()
+
+foreach ($problem in 1..5) {
+ mkdir output/$problem
+ foreach ($genfile in Get-ChildItem "generator/$problem") {
+ if ($genfile.Name -match "(.+)\.in") {
+ $genfile_id = $Matches[1]
+ Copy-Item $genfile output/$problem
+ }
+ elseif ($genfile.Name -match "(.+)\.cpp") {
+ $genfile_id = $Matches[1]
+ Push-Location "generator/$problem"
+ clang-cl $genfile.Name /O2 "-fsanitize=address,undefined"
+ Pop-Location
+ & "./generator/$problem/$genfile_id.exe" > "./output/$problem/$genfile_id.in"
+ }
+ $time = (Measure-Command {
+ Get-Content "./output/$problem/$genfile_id.in" | & "./solution/$problem.exe" > "./output/$problem/$genfile_id.out"
+ }).TotalSeconds
+
+ $time_output += "Problem $problem test point $genfile_id time: $time s."
+ }
+}
+
+foreach ($line in $time_output) {
+ Write-Output $line
+}