-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 -2 | ||
3 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-1 | ||
7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <stdio.h> | ||
int dfs(int x, int MAX) { | ||
if (x == MAX) return 1; | ||
int tmp[10] = {}; | ||
for (int i = 0; i < 10; ++i) { | ||
tmp[i] = x - i; | ||
} | ||
int res = dfs(x+1, MAX), tot = 0; | ||
for (int i = 0; i < 10; ++i) { | ||
tot += i * tmp[i] * res; | ||
} | ||
return tot; | ||
} | ||
int main() { | ||
int a, b; | ||
while(scanf("%d %d",&a, &b) != EOF) { | ||
printf("%d\n", dfs(0, 1000000)); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
echo1() { | ||
# echo in 1 line | ||
echo "$@" | tr -d "\n" | ||
} | ||
|
||
DEBUG_LOG=.debug.$$.log | ||
ERROR_LOG=error.log | ||
|
||
# Test configuring stack size | ||
src=large_stack.c | ||
# Use default stack size (8M) will cause SEGMENTATION_FAULT | ||
echo -n 'Test limitation of stack size: ' | ||
RESULT=`ljudge --debug --keep-stdout --keep-stderr --user-code $src --testcase --input 1.in --output 1.out --testcase --input 2.in --output 2.out 2> $DEBUG_LOG | cat` | ||
EXITCODE=$? | ||
if [ "$EXITCODE" != 0 ] || [ -z "$RESULT" ] || (echo1 "$RESULT" | grep -qi ERROR) || (echo1 "$RESULT" | grep -qv SEGMENTATION_FAULT); then | ||
# Log error | ||
echo `date` 'Error running' $i 'test (exit code ' $EXITCODE ')' >> $ERROR_LOG | ||
echo1 "$RESULT" >> $ERROR_LOG | ||
cat $DEBUG_LOG >> $ERROR_LOG | ||
echo >> $ERROR_LOG | ||
# notify user | ||
echo1 'ERROR' "$RESULT" | ||
echo | ||
echo 'To re-run: ljudge -u '$src' -i 1.in -o 1.out -i 2.in -o 2.out' | ||
echo | ||
else | ||
echo OKAY | ||
fi | ||
# Use larger stack size to eliminate SEGMENTATION_FAULT | ||
echo -n 'Test larger stack size: ' | ||
RESULT=`ljudge --debug --keep-stdout --keep-stderr --user-code $src --max-stack 128M --testcase --input 1.in --output 1.out --testcase --input 2.in --output 2.out 2> $DEBUG_LOG | cat` | ||
EXITCODE=$? | ||
if [ "$EXITCODE" != 0 ] || [ -z "$RESULT" ] || (echo1 "$RESULT" | grep -qi ERROR) || (echo1 "$RESULT" | grep -q SEGMENTATION_FAULT); then | ||
# Log error | ||
echo `date` 'Error running' $i 'test (exit code ' $EXITCODE ')' >> $ERROR_LOG | ||
echo1 "$RESULT" >> $ERROR_LOG | ||
cat $DEBUG_LOG >> $ERROR_LOG | ||
echo >> $ERROR_LOG | ||
# notify user | ||
echo1 'ERROR' "$RESULT" | ||
echo | ||
echo 'To re-run: ljudge -u '$src' -i 1.in -o 1.out -i 2.in -o 2.out --max-stack 128M' | ||
echo | ||
else | ||
echo OKAY | ||
fi | ||
|
||
[ -e $DEBUG_LOG ] && unlink $DEBUG_LOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters