2867 | 2023-01-31 10:44:13 | mraron | Videójáték | golang | Runtime error 0/100 | 722ms | 538528 KiB |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func inputFunc() func() []int {
scanner := bufio.NewScanner(os.Stdin)
return func() []int {
var input string
var output []int
scanner.Scan()
input = scanner.Text()
inputSplit := strings.Split(input, " ")
for i := 0; i < len(inputSplit); i++ {
charInt, _ := strconv.Atoi(inputSplit[i])
output = append(output, charInt)
}
return output
}
}
func main() {
input := inputFunc()
var aBreaks, yBreaks []int
var boretime, boretimeNow, aLenght, yLenght, output int
boretime = input()[0]
aLenght = input()[0]
for i := 0; i < aLenght; i++ {
ln := input()
aBreaks = append(aBreaks, ln[0])
aBreaks = append(aBreaks, ln[1])
}
yLenght = input()[0]
for i := 0; i < yLenght; i++ {
ln := input()
yBreaks = append(yBreaks, ln[0])
yBreaks = append(yBreaks, ln[1])
}
//chart creation
var max int
for i := 1; i < len(yBreaks); i++ {
if max < yBreaks[i] {
max = yBreaks[i]
}
}
for i := 1; i < len(aBreaks); i++ {
if max < aBreaks[i] {
max = aBreaks[i]
}
}
charta := make([]int, max)
charty := make([]int, max)
q, u := 1, 0
for {
if q > len(aBreaks) {
break
}
charta[aBreaks[q]-u-1] = 1
if aBreaks[q]-u == aBreaks[q-1] {
u = 0
q = q + 2
} else {
u++
}
//fmt.Println(charta)
}
q, u = 1, 0
for {
if q > len(yBreaks) {
break
}
charty[yBreaks[q]-u-1] = 1
if yBreaks[q]-u == yBreaks[q-1] {
u = 0
q = q + 2
} else {
u++
}
//fmt.Println(charty)
}
var index int
//fmt.Println(charta)
//fmt.Println(charty)
for i := 0; i < len(charta); i++ {
if boretime == boretimeNow {
index = i
for charta[index] != 0 {
charta[index] = 0
index++
}
boretimeNow = 0
}
if charta[i] == 1 && charta[i] != charty[i] {
boretimeNow++
}
}
for i := 0; i < len(charta); i++ {
if charta[i] == 1 && charta[i] == charty[i] {
output++
}
}
//fmt.Println(charta)
//fmt.Println(charty)
fmt.Println(output)
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 25ms | 29964 KiB | ||||
2 | Runtime error | 211ms | 538528 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Runtime error | 216ms | 538080 KiB | ||||
4 | Runtime error | 261ms | 537396 KiB | ||||
5 | Runtime error | 263ms | 537508 KiB | ||||
6 | Runtime error | 129ms | 54084 KiB | ||||
7 | Runtime error | 125ms | 53916 KiB | ||||
8 | Accepted | 611ms | 259532 KiB | ||||
9 | Accepted | 27ms | 32388 KiB | ||||
10 | Runtime error | 722ms | 536616 KiB | ||||
11 | Runtime error | 250ms | 536640 KiB | ||||
subtask3 | 0/20 | ||||||
12 | Runtime error | 123ms | 54664 KiB | ||||
13 | Runtime error | 259ms | 72008 KiB | ||||
14 | Runtime error | 250ms | 536180 KiB | ||||
15 | Accepted | 27ms | 33216 KiB | ||||
16 | Accepted | 25ms | 33864 KiB | ||||
17 | Runtime error | 250ms | 535712 KiB | ||||
18 | Runtime error | 202ms | 535496 KiB | ||||
19 | Runtime error | 250ms | 535480 KiB | ||||
20 | Wrong answer | 28ms | 34936 KiB | ||||
21 | Wrong answer | 26ms | 35108 KiB | ||||
22 | Wrong answer | 23ms | 34648 KiB | ||||
subtask4 | 0/30 | ||||||
23 | Runtime error | 149ms | 64920 KiB | ||||
24 | Accepted | 107ms | 48960 KiB | ||||
25 | Runtime error | 372ms | 74308 KiB | ||||
26 | Runtime error | 305ms | 81860 KiB | ||||
27 | Runtime error | 298ms | 76212 KiB | ||||
28 | Runtime error | 194ms | 67884 KiB | ||||
29 | Wrong answer | 41ms | 43832 KiB | ||||
30 | Wrong answer | 41ms | 43704 KiB | ||||
31 | Wrong answer | 32ms | 38220 KiB | ||||
subtask5 | 0/40 | ||||||
32 | Wrong answer | 78ms | 75156 KiB | ||||
33 | Wrong answer | 665ms | 359508 KiB | ||||
34 | Runtime error | 621ms | 534708 KiB | ||||
35 | Runtime error | 361ms | 534624 KiB | ||||
36 | Runtime error | 428ms | 534720 KiB | ||||
37 | Runtime error | 381ms | 534672 KiB | ||||
38 | Wrong answer | 187ms | 95552 KiB | ||||
39 | Wrong answer | 224ms | 107300 KiB | ||||
40 | Wrong answer | 90ms | 74324 KiB | ||||
41 | Wrong answer | 112ms | 83428 KiB |