Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EndlessCheng committed Feb 20, 2025
1 parent 97d5965 commit ddd3faa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions copypasta/template/atcoder/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,23 @@ func parseTask(session *grequests.Session, problemURL string) (sampleIns, sample
var f func(*html.Node)
f = func(o *html.Node) {
if o.Type == html.TextNode {
get := func() string {
if o.Parent.NextSibling.FirstChild != nil {
return o.Parent.NextSibling.FirstChild.Data
}
// https://atcoder.jp/contests/abc371/tasks/abc371_e
return o.Parent.NextSibling.NextSibling.FirstChild.Data
}
if inputRegex.MatchString(o.Data) {
raw := o.Parent.NextSibling.FirstChild.Data
raw := get()
raw = strings.TrimSpace(raw)
sampleIns = append(sampleIns, raw)
} else if outputRegex.MatchString(o.Data) {
if o.Parent.NextSibling.FirstChild == nil {
// 样例输出为空,例如 https://atcoder.jp/contests/abc150/tasks/abc150_f
sampleOuts = append(sampleOuts, "")
} else {
raw := o.Parent.NextSibling.FirstChild.Data
raw := get()
raw = strings.TrimSpace(raw)
sampleOuts = append(sampleOuts, raw)
}
Expand Down

0 comments on commit ddd3faa

Please sign in to comment.