class PathTask(Task): id = 'path' tests = [ Test(id='01', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='02', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='03', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='04', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='05', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='06', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='07', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='08', time=1.0, score=75.0/30.0, dat=None, chk=None), Test(id='09', time=2.0, score=75.0/30.0, dat=None, chk=None), Test(id='10', time=2.0, score=75.0/30.0, dat=None, chk=None), ] eps = 10e-5 def load_dat(self, stream): N = self.read(stream, int) AX, AY = self.read(stream, float, float) BX, BY = self.read(stream, float, float) rectangles = [] for k in range(N): x1, y1, x2, y2 = self.read(stream, float, float, float, float) rectangles.append((x1, y1, x2, y2)) return Dat(A=(AX, AY), B=(BX, BY), rectangles=rectangles) def load_chk(self, stream): X = self.read(stream, float) return Chk(X=X) def save_dat(self, stream, dat): self.write(stream, len(dat.rectangles)) self.write(stream, *dat.A) self.write(stream, *dat.B) for rectangle in dat.rectangles: self.write(stream, *rectangle) def load_sol(self, stream): X = self.read(stream, float) return Chk(X=X) def verify(self, dat, chk, sol): if abs(chk.X-sol.X) > self.eps: raise Break, 'WA' raise Break, 'OK'