Skip to content

Instantly share code, notes, and snippets.

@ouuan
Last active October 22, 2021 07:38
Show Gist options
  • Select an option

  • Save ouuan/480179fcfa21cf4cb89247d69dfb33e9 to your computer and use it in GitHub Desktop.

Select an option

Save ouuan/480179fcfa21cf4cb89247d69dfb33e9 to your computer and use it in GitHub Desktop.
将 namex-x.in 格式的数据改成 namex.in 格式的,输出 UOJ 格式的 subtask_end
ls *.in | sort -V | awk '{
begin = match($0, /-[0-9]*/) + 1;
if (substr($0, begin, RLENGTH - 1) == "1") {
if (subtask > 0) print "subtask_end_" subtask " " NR - 1 ;
++subtask;
if (!getline line) print "subtask_end_" subtask " " NR;
}
}'
ls *.in | sort -V | awk '{tmp = $0; gsub(/[0-9]*-[0-9]*/, NR); system("cp " tmp " " $0);}'
ls *.out | sort -V | awk '{tmp = $0; gsub(/[0-9]*-[0-9]*/, NR); system("cp " tmp " " $0);}'
ls *.ans | sort -V | awk '{tmp = $0; gsub(/[0-9]*-[0-9]*/, NR); system("cp " tmp " " $0);}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment