Skip to content

Commit

Permalink
aaa
Browse files Browse the repository at this point in the history
  • Loading branch information
WangSenyuan committed Jun 7, 2024
1 parent 9348480 commit 07b1d45
Show file tree
Hide file tree
Showing 8 changed files with 955 additions and 0 deletions.
158 changes: 158 additions & 0 deletions src/atcoders/abc/abc34/abc343/e/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
In a coordinate space, we want to place three cubes with a side length of
7 so that the volumes of the regions contained in exactly one, two, three cube(s) are
V
1
,
V
2
,
V
3
, respectively.

For three integers
a,
b,
c, let
C(a,b,c) denote the cubic region represented by
(a≤x≤a+7)∧(b≤y≤b+7)∧(c≤z≤c+7).

Determine whether there are nine integers
a
1
,b
1
,c
1
,a
2
,b
2
,c
2
,a
3
,b
3
,c
3
that satisfy all of the following conditions, and find one such tuple if it exists.

∣a
1
∣,∣b
1
∣,∣c
1
∣,∣a
2
∣,∣b
2
∣,∣c
2
∣,∣a
3
∣,∣b
3
∣,∣c
3
∣≤100
Let
C
i
=C(a
i
,b
i
,c
i
) (i=1,2,3).
The volume of the region contained in exactly one of
C
1
,C
2
,C
3
is
V
1
.
The volume of the region contained in exactly two of
C
1
,C
2
,C
3
is
V
2
.
The volume of the region contained in all of
C
1
,C
2
,C
3
is
V
3
.


### ideas
1. v1是,a, b, c包含只在任意一个区域中(不在重叠区域)的点的数量
2. v2是在任意两个重叠区域中的点的数量
3. v3时在3个重叠区域中的点的数量
4. V * 3 = v1 - v2 + v3
5. = 840 + 84 + 7 = 931
6. 6 * 6 * 7 + 6 * 7 * 7 + 6 * 7 * 7 = 840
7. v1 + v2 + v3 <= V * 3 = 1029
8. vx = V * 3 - v2 - 2 * v3 = 表示的是,在任意一个区域中的点的数量
9. = 1029 - 84 - 14 = 952 = v1 + v2 + v3 = 931
10. 3 * V = v1 + 2 * v2 + 3 * v3 成立时,始终是结果的
11. 第一个立方体的位置是确定的, 就在原点
12. 考虑v3, = h * w * l 分别表示,任意两个立方体重叠的距离
13. 考虑到v3比较小(h, w, l <= 7) 似乎是可以迭代的
14. 其中 (h, w) 是和第一个立方体重叠的高度和深度
15. 有了这两个信息,可以确定 第二个立方体的位置
16. 同样的,可以把 (h, l)来确定第三个立方体的位置(并用 w, l来验证2和3的位置)
172 changes: 172 additions & 0 deletions src/atcoders/abc/abc34/abc343/e/solution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package main

import (
"bufio"
"bytes"
"fmt"
"os"
)

func main() {
reader := bufio.NewReader(os.Stdin)

v1, v2, v3 := readThreeNums(reader)

res := solve(v1, v2, v3)

if len(res) == 0 {
fmt.Println("No")
return
}
var buf bytes.Buffer
buf.WriteString("Yes\n")
for i := 0; i < len(res); i++ {
buf.WriteString(fmt.Sprintf("%d ", res[i]))
}
buf.WriteByte('\n')

fmt.Print(buf.String())
}

func readString(r *bufio.Reader) string {
s, _ := r.ReadString('\n')
for i := 0; i < len(s); i++ {
if s[i] == '\n' || s[i] == '\r' {
return s[:i]
}
}
return s
}

func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}

func readNum(reader *bufio.Reader) (a int) {
bs, _ := reader.ReadBytes('\n')
readInt(bs, 0, &a)
return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
res := readNNums(reader, 2)
a, b = res[0], res[1]
return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
res := readNNums(reader, 3)
a, b, c = res[0], res[1], res[2]
return
}

func readNNums(reader *bufio.Reader, n int) []int {
res := make([]int, n)
x := 0
bs, _ := reader.ReadBytes('\n')
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
x = readInt(bs, x, &res[i])
}
return res
}

const V = 7 * 7 * 7

var pos []int

func init() {
for i := -7; i <= 7; i++ {
pos = append(pos, i)
}
}

func solve(v1, v2, v3 int) []int {
// 这个是只要在一个区域内
sum := v1 + v2 + v3

if v1+2*v2+3*v3 != 3*V || sum < V {
return nil
}

get2 := func(first []int, second []int) int {
res := 1
for i := 0; i < 3; i++ {
res *= max(0, min(first[i], second[i])+7-max(first[i], second[i]))
}
return res
}

get3 := func(first []int, second []int, third []int) int {
res := 1
for i := 0; i < 3; i++ {
res *= max(0, min3(first[i], second[i], third[i])+7-max3(first[i], second[i], third[i]))
}

return res
}

first := []int{0, 0, 0}

for _, a2 := range pos {
for _, b2 := range pos {
for _, c2 := range pos {
second := []int{a2, b2, c2}
for _, a3 := range pos {
for _, b3 := range pos {
for _, c3 := range pos {
third := []int{a3, b3, c3}
nv3 := get3(first, second, third)
if nv3 != v3 {
continue
}
nv2 := get2(first, second) + get2(first, third) + get2(second, third) - 3*nv3
if nv2 != v2 {
continue
}
return []int{0, 0, 0, a2, b2, c2, a3, b3, c3}
}
}
}
}
}
}

return nil
}

func max(a, b int) int {
if a >= b {
return a
}
return b
}

func max3(a, b, c int) int {
return max(a, max(b, c))
}

func min(a, b int) int {
if a <= b {
return a
}
return b
}

func min3(a, b, c int) int {
return min(a, min(b, c))
}
17 changes: 17 additions & 0 deletions src/codeforces/set0/set6/set650/set650/d/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in the forest. He is sure that he remembers correct heights of all trees except, possibly, one of them.

It is known that the forest consists of n trees staying in a row numbered from left to right with integers from 1 to n. According to Vasya, the height of the i-th tree is equal to hi. The zip-line of length k should hang over k (1 ≤ k ≤ n) trees i1, i2, ..., ik (i1 < i2 < ... < ik) such that their heights form an increasing sequence, that is hi1 < hi2 < ... < hik.

Petya had been in this forest together with Vasya, and he now has q assumptions about the mistake in Vasya's sequence h. His i-th assumption consists of two integers ai and bi indicating that, according to Petya, the height of the tree numbered ai is actually equal to bi. Note that Petya's assumptions are independent from each other.

Your task is to find the maximum length of a zip-line that can be built over the trees under each of the q assumptions.

In this problem the length of a zip line is considered equal to the number of trees that form this zip-line.



### ideas
1. 原来的算法确实有点问题
2. prev应该等于,在i前面的,最大的lis中的位置,在位置相同时,应该是最小的那个值
3. a[i]变大后,如果它原来在lis中,那么它对后面的贡献有可能被取消掉,但有可能会增加对前面的贡献
4.
Loading

0 comments on commit 07b1d45

Please sign in to comment.