|
@@ -0,0 +1,52 @@
|
|
|
|
|
+package main
|
|
|
|
|
+
|
|
|
|
|
+import "strconv"
|
|
|
|
|
+import "bufio"
|
|
|
|
|
+import "fmt"
|
|
|
|
|
+import "os"
|
|
|
|
|
+
|
|
|
|
|
+type Compressed struct {
|
|
|
|
|
+ BSize int
|
|
|
|
|
+ Count int
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func ReadCompressed(line string) *Compressed {
|
|
|
|
|
+ if (line[0] != '(' || line[len(line) -1] != ')') {
|
|
|
|
|
+ return nil
|
|
|
|
|
+ }
|
|
|
|
|
+ line = line[1:len(line)-1]
|
|
|
|
|
+ fmt.Println(">>>" +line +"<<<")
|
|
|
|
|
+ this := new(Compressed)
|
|
|
|
|
+ this.BSize = 0
|
|
|
|
|
+ return this
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func main() {
|
|
|
|
|
+ reader := bufio.NewReader(os.Stdin)
|
|
|
|
|
+ length := 0
|
|
|
|
|
+
|
|
|
|
|
+ for true {
|
|
|
|
|
+ line, err := reader.ReadString('(')
|
|
|
|
|
+ if line[len(line) -1] == '(' {
|
|
|
|
|
+ line = line[0: len(line) -1]
|
|
|
|
|
+ reader.UnreadByte()
|
|
|
|
|
+ }
|
|
|
|
|
+ length += len(line)
|
|
|
|
|
+ fmt.Println(line)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ line, err = reader.ReadString(')')
|
|
|
|
|
+ compressed := ReadCompressed(line)
|
|
|
|
|
+ if (compressed == nil) {
|
|
|
|
|
+ length += len(line)
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ fmt.Println("len: " +strconv.Itoa(length))
|
|
|
|
|
+}
|
|
|
|
|
+
|