Skip to content

Commit 954b70c

Browse files
committed
upd
1 parent 58bfc99 commit 954b70c

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

Diff for: copypasta/template/interactive_problem/main.go

+16-28
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type stdIO struct {
2020

2121
type (
2222
initData struct{ n int }
23-
request struct{ q int } //
24-
response struct{ res int }
23+
request struct{ q int }
24+
response struct{ v int }
2525
answer struct{ ans int }
2626
)
2727

@@ -41,19 +41,12 @@ func (io stdIO) query(q request) (resp response) {
4141
Fprintln(out, "?", q.q)
4242
//Fprint(out, "?")
4343
//Fprint(out, " ", len(q.q)) // TODO 输出 query 长度?
44-
//for _, v := range q.q {
45-
// Fprint(out, " ", v)
46-
//}
44+
//for _, v := range q.q { Fprint(out, " ", v) }
4745
//Fprintln(out)
4846

4947
out.Flush()
50-
51-
Fscan(in, &resp.res)
52-
53-
// TODO: 题目定义了 incorrect request?
54-
if resp.res < 0 {
55-
panic(-1)
56-
}
48+
Fscan(in, &resp.v)
49+
//if resp.v < 0 { panic(-1) }
5750
return
5851
}
5952

@@ -63,18 +56,15 @@ func (io stdIO) printAnswer(a answer) {
6356
Fprintln(out, "!", a.ans)
6457
//Fprint(out, "!")
6558
//Fprint(out, " ", len(a.ans)) // TODO 输出答案长度?
66-
//for _, v := range a.ans {
67-
// Fprint(out, " ", v)
68-
//}
59+
//for _, v := range a.ans { Fprint(out, " ", v) }
6960
//Fprintln(out)
7061

7162
out.Flush()
7263

7364
// TODO judge 是否返回答案非法?(通常是 move on to the next test case)
74-
//var res int
75-
//if Fscan(io.in, &res); res < 0 {
76-
// panic(res)
77-
//}
65+
//var state int
66+
//Fscan(io.in, &state)
67+
//if state < 0 { panic(state) }
7868
}
7969

8070
func doInteraction(it interaction) {
@@ -84,13 +74,11 @@ func doInteraction(it interaction) {
8474
_ = n
8575

8676
// TODO query 格式?
87-
q := func(q int) int {
88-
//for i := range q {
89-
// q[i]++
90-
//}
91-
return it.query(request{q}).res
77+
get := func(q int) int {
78+
//for i := range q { q[i]++ }
79+
return it.query(request{q}).v
9280
}
93-
_ = q
81+
_ = get
9482

9583
// TODO 答案类型?
9684
var ans int
@@ -101,6 +89,9 @@ func doInteraction(it interaction) {
10189

10290
}
10391

92+
// TODO: 运行 & 测试!检查格式是否正确
93+
func main() { run() }
94+
10495
func run() {
10596
in := bufio.NewReader(os.Stdin)
10697
out := bufio.NewWriter(os.Stdout)
@@ -112,6 +103,3 @@ func run() {
112103
doInteraction(stdIO{in, out})
113104
}
114105
}
115-
116-
// TODO: 运行 & 测试!检查格式是否正确
117-
func main() { run() }

Diff for: copypasta/template/interactive_problem/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (io *mockIO) query(q request) (resp response) {
6868
io.queryCnt++
6969
if io.queryCnt > io.queryLimit { io._t.Fatalf("Query Limit Exceeded %d\nCase Data:\n%v", io.caseNum, io) }
7070

71-
// TODO: 计算 resp.res ...
71+
// TODO: 计算 resp.v ...
7272
//a := io.hiddenData
7373
//qs := q.q
7474
//for i := range qs {

0 commit comments

Comments
 (0)