← Home
For problem statement at 0-999/600-699/610-619/618/problemE.txt this is a correct solution, but verifier at 0-999/600-699/610-619/618/verifierE.go ends with internal parse error: expected two floats
exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

type Node struct {
	x, y float64
	lazy int
}

var (
	tree    []Node
	cos_deg [360]float64
	sin_deg [360]float64
)

func build(u, l, r int) {
	if l == r {
		tree[u].x = 1.0
		tree[u].y = 0.0
		tree[u].lazy = 0
		return
	}
	mid := (l + r) / 2
	build(u*2, l, mid)
	build(u*2+1, mid+1, r)
	push_up(u)
}

func push_up(u int) {
	tree[u].x = tree[u*2].x + tree[u*2+1].x
	tree[u].y = tree[u*2].y + tree[u*2+1].y
}

func apply_rot(u int, d int) {
	nx := tree[u].x*cos_deg[d] - tree[u].y*sin_deg[d]
	ny := tree[u].x*sin_deg[d] + tree[u].y*cos_deg[d]
	tree[u].x = nx
	tree[u].y = ny
	tree[u].lazy = (tree[u].lazy + d) % 360
}

func push_down(u int) {
	if tree[u].lazy != 0 {
		apply_rot(u*2, tree[u].lazy)
		apply_rot(u*2+1, tree[u].lazy)
		tree[u].lazy = 0
	}
}

func update_extend(u, l, r, idx int, val float64) {
	if l == r {
		len := math.Hypot(tree[u].x, tree[u].y)
		tree[u].x += tree[u].x / len * val
		tree[u].y += tree[u].y / len * val
		return
	}
	push_down(u)
	mid := (l + r) / 2
	if idx <= mid {
		update_extend(u*2, l, mid, idx, val)
	} else {
		update_extend(u*2+1, mid+1, r, idx, val)
	}
	push_up(u)
}

func update_rotate(u, l, r, ql, qr, d int) {
	if ql <= l && r <= qr {
		apply_rot(u, d)
		return
	}
	push_down(u)
	mid := (l + r) / 2
	if ql <= mid {
		update_rotate(u*2, l, mid, ql, qr, d)
	}
	if qr > mid {
		update_rotate(u*2+1, mid+1, r, ql, qr, d)
	}
	push_up(u)
}

func readInt(in *bufio.Reader) int {
	var res int
	var c byte
	var err error
	for {
		c, err = in.ReadByte()
		if err != nil {
			return 0
		}
		if c >= '0' && c <= '9' {
			break
		}
	}
	res = int(c - '0')
	for {
		c, err = in.ReadByte()
		if err != nil || c < '0' || c > '9' {
			break
		}
		res = res*10 + int(c - '0')
	}
	return res
}

func main() {
	for i := 0; i < 360; i++ {
		rad := float64(i) * math.Pi / 180.0
		cos_deg[i] = math.Cos(rad)
		sin_deg[i] = math.Sin(rad)
	}

	in := bufio.NewReaderSize(os.Stdin, 1<<20)
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	n := readInt(in)
	m := readInt(in)

	tree = make([]Node, 4*n+1)
	if n > 0 {
		build(1, 1, n)
	}

	for i := 0; i < m; i++ {
		typ := readInt(in)
		idx := readInt(in)
		val := readInt(in)

		if typ == 1 {
			update_extend(1, 1, n, idx, float64(val))
		} else {
			d := (360 - (val % 360)) % 360
			update_rotate(1, 1, n, idx, n, d)
		}
		fmt.Fprintf(out, "%.10f %.10f\n", tree[1].x, tree[1].y)
	}
}