Skip to content

Commit 586fe71

Browse files
committed
[1900] CF1600E 博弈 首尾取数构造严格递增 结论题 分类讨论
1 parent 7315ec7 commit 586fe71

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

main/1600-1699/1600E.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
)
8+
9+
// github.com/EndlessCheng/codeforces-go
10+
func CF1600E(_r io.Reader, out io.Writer) {
11+
in := bufio.NewReader(_r)
12+
var n int
13+
Fscan(in, &n)
14+
a := make([]int, n)
15+
for i := range a {
16+
Fscan(in, &a[i])
17+
}
18+
19+
p, q := 1, n-1
20+
for ; p < n && a[p-1] < a[p]; p++ {}
21+
for ; q > 0 && a[q] < a[q-1]; q-- {}
22+
if p&1 > 0 || (n-q)&1 > 0 {
23+
Fprint(out, "Alice")
24+
} else {
25+
Fprint(out, "Bob")
26+
}
27+
}
28+
29+
//func main() { CF1600E(os.Stdin, os.Stdout) }

main/1600-1699/1600E_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"github.com/EndlessCheng/codeforces-go/main/testutil"
5+
"testing"
6+
)
7+
8+
// https://codeforces.com/problemset/problem/1600/E
9+
// https://codeforces.com/problemset/status/1600/problem/E
10+
func TestCF1600E(t *testing.T) {
11+
// just copy from website
12+
rawText := `
13+
inputCopy
14+
1
15+
5
16+
outputCopy
17+
Alice
18+
inputCopy
19+
3
20+
5 4 5
21+
outputCopy
22+
Alice
23+
inputCopy
24+
6
25+
5 8 2 1 10 9
26+
outputCopy
27+
Bob`
28+
testutil.AssertEqualCase(t, rawText, 0, CF1600E)
29+
}

0 commit comments

Comments
 (0)