Problem:


線対称

平面上の異なる 3 点 P1(x1,y1), P2(x2,y2), Q(xq,yq) の座標の組を読み込んで、点 P1 点P2 を通る直線を対称軸として点 Q と線対称の位置にある点 R(x,y) を出力するプログラムを作成してください。なお、点 Q は、その対称軸上にないものとします。

入力

入力は複数のデータセットからなります。各データセットは以下の形式で与えられます。

x1,y1,x2,y2,xq,yq

x1, y1, x2, y2, xq, yq (-100 以上 100 以下の実数) がカンマ区切りで１行に与えられます。

データセットの数は 50 を超えない。

出力

データセットごとに、x, y を空白区切りで 1 行に出力する。出力は実数で 0.0001 以下の誤差を含んでもよい。

Sample Input

1.0,0.0,-1.0,0.0,1.0,1.0 
1.0,0.0,0.0,-1.0,3.0,0.0 
0.0,1.0,0.0,-1.0,1.0,1.0 

Output for the Sample Input

1.000000 -1.000000
1.000000 2.000000
-1.000000 1.000000



Sample input:
1.0,0.0,-1.0,0.0,1.0,1.0
1.0,0.0,0.0,-1.0,3.0,0.0
0.0,1.0,0.0,-1.0,1.0,1.0


Sample output:
1.000000 -1.000000
1.000000 2.000000
-1.000000 1.000000

Submission status: Wrong Answer

Solution code:
def dot(x, y):
    return (x.conjugate() * y).real
    
def project(p, d):
    return dot(p, d) / abs(d)

def line_sym(p, p1, p2):
    d = p2 - p1
    p = p - p1
    #return p - 2 * (p - project(p, d)) 
    return (2 * project(p, d) - p) + p1

import sys

p = []
for line in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, line.split(','))
    p1 = complex(x1, y1)
    p2 = complex(x2, y2)
    q = complex(xq, yq)
    
    r = line_sym(q, p1, p2)
    
    print(r.real, r.imag)

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin:
    x1,y1,x2,y2,xq,yq = map(float, line.split(','))
    if x1 == x2:
        print(2*x1-xq,yq)
        continue
    else:
        a = (y2-y1)/(x2-x1)
        d = y1 - a*x1
        if a == 1:
            print("a = 1", yq-d, xq+d)
            continue
        elif a == -1:
            print(-yq+d, -xq+d)
            continue
        else:
            print(xq-2*a*(yq-d)/(a**2-1), (a**2*yq+2*a*xq+2*d-yq)/(1-a**2))

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin:
    x1,y1,x2,y2,xq,yq = map(float, line.split(','))
    if x1 == x2:
        print(2*x1-xq,yq)
        continue
    else:
        a = (y2-y1)/(x2-x1)
        d = y1 - a*x1
        if a == 1:
            print(yq-d, xq+d)
            continue
        elif a == -1:
            print(-yq+d, -xq+d)
            continue
        else:
            print(xq-2*a*(yq-d)/(a**2-1), (a**2*yq+2*a*xq+2*d-yq)/(1-a**2))

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin:
    x1,y1,x2,y2,xq,yq = map(float, line.split(','))
    if x1 == x2:
        x = 2*x1-xq
        y = yq
        if x == -0:
            x = 0
        if y == -0:
            y = 0
        print(x, y)
        continue
    else:
        a = (y2-y1)/(x2-x1)
        d = y1 - a*x1
        if a == 1:
            x = yq-d
            y = xq+d
            if x == -0:
                x = 0
            if y == -0:
                y = 0
            print(x, y)
            continue
        elif a == -1:
            x = -yq+d
            y = -xq+d
            if x == -0:
                x = 0
            if y == -0:
                y = 0
            print(x, y)
            continue
        else:
            x = xq-2*a*(yq-d)/(a**2-1)
            y = (a**2*yq+2*a*xq+2*d-yq)/(1-a**2)
            if x == -0:
                x = 0
            if y == -0:
                y = 0
            print(x, y)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, s.split(','))

    vx = x2 - x1
    vy = y2 - y1
    l = math.sqrt(vx ** 2 + vy ** 2)
    nx = vx / l
    ny = vy / l
    N = (nx, ny) # unit vector

    # O is between P1, P2
    PQ = (xq - x1, yq - y1)
    cross = N[0] * PQ[0] + N[1] * PQ[1]
    PO = (nx * cross, ny * cross)

    #OQ = PQ - PO
    OQ = (PQ[0] - PO[0], PQ[1] - PO[1])

    rx = x1 + PO[0] - OQ[0]
    ry = y1 + PO[1] - OQ[1]
    print('{} {}'.format(rx, ry))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

class Vector2():
    def __init__(self, x, y):
        self._x = float(x)
        self._y = float(y)

    def normalize(self):
        norm = self.norm()
        return Vector2(self._x / norm, self._y / norm)

    def norm(self):
        return math.sqrt(self._x ** 2 + self._y ** 2)

    def dot(self, other):
        return self._x * other._x + self._y * other._y

    def __add__(self, other):
        return Vector2(self._x + other._x, self._y + other._y)

    def __sub__(self, other):
        return Vector2(self._x - other._x, self._y - other._y)

    def __str__(self):
        return "{} {}".format(self._x, self._y)

    def __mul__(self, scale):
        return Vector2(self._x * scale, self._y * scale)


for s in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, s.split(','))

    OP1 = Vector2(x1, y1)
    OP2 = Vector2(x2, y2)
    OQ = Vector2(xq, yq)

    P2P1 = OP2 - OP1
    N = P2P1.normalize()

    P1Q = OQ - OP1

    # projection
    dot = P1Q.dot(N)
    P1O = N * dot

    QO = P1O - P1Q
    OR = OP1 + P1O + QO

    print(OR)

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for x in sys.stdin:
 a,b,c,d,e,f=map(float,x.split(','))
 g=atan2(b-d,a-c)*2
 print(e*cos(g)+f*sin(g),e*sin(g)-f*cos(g))

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for x in sys.stdin:
 a,b,c,d,e,f=map(float,x.split(','))
 g=2*atan2(b-d,a-c)
 print(e*cos(g)+f*sin(g),e*sin(g)-f*cos(g))

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,e,f=map(float,e.split(','))
 g=2*atan2(b-d,a-c);s,t,x,y=sin(g),cos(g),e-a,f-b
 print(t*x+s*y+a,s*x-t*y+b)

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(b-d,a-c);s,t=sin(g),cos(g);x-=a;y-=b
 print(t*x+s*y+a,s*x-t*y+b)

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(t*x+s*y+a,s*x-t*y+b)

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x+s*y+a:.6} {s*x-t*y+b:.6}')

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=-2*(atan2(x-b,y-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b
 print(t*x-s*y+a,s*x+t*y+b)

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=-2*(atan2(x-b,y-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x-s*y+a:.6} {s*x+t*y+b:.6}')

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=-2*(atan2(x-b,y-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x-s*y+a:.6f} {s*x+t*y+b:.6f}')

Submission status: Wrong Answer

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2.*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(t*x+s*y+a,s*x-t*y+b)

Submission status: Wrong Answer

Solution code:
while 1:
  try:
    x1,y1,x2,y2,xq,yq=list(map(float,input().split(",")))
  except:
    break
  X=((2*x1-xq)*((y1-y2)**2)+xq*((x1-x2)**2)+2*(y1+yq)*(x1-x2)*(y1-y2))/((x1-x2)**2+(y1-y2)**2)
  try:
    Y=(y1-y2)/(x1-x2)*(X+xq-2*x1)+2*y1-yq
  except:
    Y=-(x1-x2)/(y1-y2)*(X-xq)+yq
  print(X,Y)

Submission status: Wrong Answer

Solution code:
while 1:
  try:
    x1,y1,x2,y2,xq,yq=list(map(float,input().split(",")))
  except:
    break
  X=(((2*x1-xq)*(y1-y2)**2)+xq*(x1-x2)**2+2*(y1+yq)*(x1-x2)*(y1-y2))/((x1-x2)**2+(y1-y2)**2)

  try:
    Y=(y1-y2)/(x1-x2)*(X+xq-2*x1)+2*y1-yq
  except:
    Y=-(x1-x2)/(y1-y2)*(X-xq)+yq
  print(" ".join(["{:.6f}".format(i) for i in [X,Y]]))

Submission status: Wrong Answer

Solution code:
import sys
for l in sys.stdin:
  x1,y1,x2,y2,xq,yq=list(map(float,l.split(",")))
  X=(((2*x1-xq)*(y1-y2)**2)+xq*(x1-x2)**2+2*(y1+yq)*(x1-x2)*(y1-y2))/((x1-x2)**2+(y1-y2)**2)

  try:
    Y=(y1-y2)/(x1-x2)*(X+xq-2*x1)+2*y1-yq
  except:
    Y=-(x1-x2)/(y1-y2)*(X-xq)+yq
  print(" ".join(["{:.6f}".format(i) for i in [X,Y]]))

Submission status: Wrong Answer

Solution code:
def vec(s,t):
    return [y-x for x,y in zip(s,t)]

def dot(a,b):
    return sum([x*y for x,y in zip(a,b)])

def scal(a):
    return (a[0]**2+a[1]**2)**0.5

def project(p,a,b):
    k = dot(vec(a,p),vec(a,b)) / scal(vec(a,b))
    return [x+(k/scal(vec(a,b)))*(y-x) for x,y in zip(a,b)]

def symmetrical_point(p,q):
    return [x+2*(y-x) for x,y in zip(p,q)]

while True:
    try:
        tmp = [float(x) for x in input().split(',')]
        p1 = [tmp[0],tmp[1]]
        p2 = [tmp[2],tmp[3]]
        q = [tmp[4],tmp[5]]
        r = symmetrical_point(q,project(q,p1,p2))
        print(r[0], r[1])
    except:
        break

Submission status: Wrong Answer

Solution code:
def vec(s,t):
    return [y-x for x,y in zip(s,t)]

def dot(a,b):
    return sum([x*y for x,y in zip(a,b)])

def scal(a):
    return (a[0]**2+a[1]**2)**0.5

def project(p,a,b):
    k = dot(vec(a,p),vec(a,b)) / scal(vec(a,b))**2
    return [x+k*(y-x) for x,y in zip(a,b)]

def symmetrical_point(p,q):
    return [x+2*(y-x) for x,y in zip(p,q)]

while True:
    try:
        tmp = [float(x) for x in input().split(',')]
        p1 = [tmp[0],tmp[1]]
        p2 = [tmp[2],tmp[3]]
        q = [tmp[4],tmp[5]]
        r = symmetrical_point(q,project(q,p1,p2))
        print(r[0], r[1])
    except:
        break

Submission status: Wrong Answer

Solution code:
import sys,math
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    L=((x1-x2)**2+(y1-y2)**2)**0.5
    t=math.atan2(y2-y1,x2-x1)
    R1=((x1-xq)**2+(y1-yq)**2)**0.5
    R2=((x2-xq)**2+(y2-yq)**2)**0.5
    a=math.acos((L*L+R1*R1-R2*R2)/(2*L*R1))
    x,y=x1+R1*math.cos(t+a),y1+R1*math.sin(t+a)
    if not (xq-0.00001<=x<=xq+0.00001 and yq-0.00001<=y<=yq+0.00001):
        print x,y
    else:
        print x1+R1*math.cos(t-a),y1+R1*math.sin(t-a)
#temp

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1-x2==0:
        print "{} {}".format(-xq+x1,yq)
    elif y1-y2==0:
        print "{} {}".format(xq,-yq+y1)
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        print "{} {}".format(1/m*yq-n,m*xq+n)

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1-x2==0:
        x,y=-xq+x1,yq
    elif y1-y2==0:
        x,y=xq,-yq+y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x,y=1/m*yq-n,m*xq+n
    print "{:.6f} {:.6f}".format(x,y)

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1-x2==0:
        x,y=-xq+x1,yq
    elif y1-y2==0:
        x,y=xq,-yq+y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x,y=1/m*yq-n,m*xq+n
    print "{:.6f} {:.6f}".format(x+0,y+0)

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1==x2:
        x,y=-xq+2*x1,yq
    elif y1==y2:
        x,y=xq,-yq+2*y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x,y=1/m*yq-n,m*xq+n
    print "{:.6f} {:.6f}".format(x+0,y+0)

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1==x2:
        x,y=-xq+2*x1,yq
    elif y1==y2:
        x,y=xq,-yq+2*y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x,y=(yq-n)/m,m*xq+n
    print "{:.6f} {:.6f}".format(x+0,y+0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    x1, y1, x2, y2, xq, yq = (float(s) for s in line.split(','))
    if x1 - x2 == 0.0:
        xr, yr = -xq, yq
    elif y1 - y2 == 0.0:
        xr, yr = xq, -yq
    else:
        m = (y1 - y2) / (x1 - x2)
        n = y1 - m * x1
        xr = xq - (2.0 * m * (m*xq - yq + n)) / (m*m + 1.0)
        yr = yq - (-2.0 * (m*xq - yq + n)) / (m*m + 1.0)
    print('{:.6f} {:.6f}'.format(xr, yr))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    x1, y1, x2, y2, xq, yq = (float(s) for s in line.split(','))
    if x1 - x2 == 0.0:
        xr, yr = -xq, yq
    elif y1 - y2 == 0.0:
        xr, yr = xq, -yq
    else:
        a = (y1 - y2) / (x1 - x2)
        c = -y1 - a * x1
        xr = xq - (2.0 * a * (a*xq - yq + c)) / (a*a + 1.0)
        yr = yq - (-2.0 * (a*xq - yq + c)) / (a*a + 1.0)
    print('{:.6f} {:.6f}'.format(xr, yr))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    x1, y1, x2, y2, xq, yq = (float(s) for s in line.split(','))
    if x1 == x2:
        print('{:.6f} {:.6f}'.format(-xq, yq))
    else:
        y = y2 - y1
        x = x2 - x1
        a = y / x
        b = -1
        c = -y1 - a*x1

        xr = xq - (2*a * (a*xq - yq + c)) / (a*a + 1)
        yr = yq - (-2 * (a*xq - yq + c)) / (a*a + 1)
        print('{:.6f} {:.6f}'.format(xr, yr))

Submission status: Wrong Answer

Solution code:
def sp(a,b,c,xq,yq):
    xr = xq - 2*a*(a*xq+b*yq+c)/(a**2+b**2)
    yr = yq - 2*b*(a*xq+b*yq+c)/(a**2+b**2)
    return xr,yr

while True:
    try:
        x1,y1,x2,y2,xq,yq = map(float, raw_input().split(","))
        print sp(y2-y1,-(x2-x1),x2*y1-x1*y2)
    except:
        break

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    x1,y1,x2,y2,xq,yq = map(float,s.split(","))
    dx,dy = x2-x1,y2-y1
    det = dx*dx+dy*dy
    y0 = dx*(y1*dx-x1*dy) + dy*(yq*dy+xq*dx)
    x0 = -dy*(y1*dx-x1*dy) + dx*(yq*dy+xq*dx)
    x0 /= det
    y0 /= det
    xp = x0+(x0-xq)
    yp = y0+(y0-yq)
    print xp,yp

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)

for line in f:
    p1,p2,pq = [x + y * 1j for x, y in take2(map(float, line.split(',')))]
    
    v21 = p2 - p1
    vq1 = pq - p1
    px = vq1* (v21.real - v21.imag * 1j)
    px = px.real - px.imag * 1j
    px /= abs(px)
    pp = p1 + (vq1) * px * px
    print('{:.6f} {:.6f}'.format(pp.real,pp.imag))

Submission status: Accepted

Solution code:
def sp(a,b,c,xq,yq):
    xr=xq-2*a*(a*xq+b*yq+c)/(a**2+b**2)
    yr=yq-2*b*(a*xq+b*yq+c)/(a**2+b**2)
    print xr,yr

while 1:
    try:
        x1,y1,x2,y2,xq,yq=map(float,raw_input().split(','))
        sp(y2-y1,-(x2-x1),x2*y1-x1*y2,xq,yq)
    except:
        break

Submission status: Accepted

Solution code:
def dot(x, y):
    return (x.conjugate() * y).real
    
def project(p, d):
    return dot(p, d) / abs(d)

def line_sym(p, x1, x2):
    p -= x1
    d = x2 -x1
    return d * p.conjugate() / d.conjugate() + x1

import sys

p = []
for line in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, line.split(','))
    p1 = complex(x1, y1)
    p2 = complex(x2, y2)
    q = complex(xq, yq)
    
    r = line_sym(q, p1, p2)
    
    print(r.real, r.imag)

Submission status: Accepted

Solution code:
def line_sym(p, x1, x2):
    p -= x1
    d = x2 -x1
    return d * p.conjugate() / d.conjugate() + x1
 
import sys
 
p = []
for line in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, line.split(','))
    p1 = complex(x1, y1)
    p2 = complex(x2, y2)
    q = complex(xq, yq)
     
    r = line_sym(q, p1, p2)
     
    print(r.real, r.imag)

Submission status: Accepted

Solution code:
while 1:
    try:
        x,y,xx,yy,l,ll=map(float,input().split(','))
        p=complex(x,y)
        pp=complex(xx,yy)
        lp=complex(l,ll)
        lp-=p
        a=pp-p
        b=a*lp.conjugate()/a.conjugate()+p
        print(b.real,b.imag)
    except:break

Submission status: Accepted

Solution code:
from math import *
while True:
    try:
        x1,y1,x2,y2,xp,yp= map(float, input().split(','))
    except:
        break
    ang, x, y= (atan2(yp-y1, xp-x1)-atan2(y2-y1, x2-x1)) * -2.0, xp-x1, yp-y1
    print("{0:.6f} {1:.6f}".format(x*cos(ang)-y*sin(ang)+x1,y*cos(ang)+x*sin(ang)+y1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

class Vector2():
    def __init__(self, x, y):
        self._x = float(x)
        self._y = float(y)

    def normalize(self):
        norm = self.norm()
        return Vector2(self._x / norm, self._y / norm)

    def norm(self):
        return math.sqrt(self._x ** 2 + self._y ** 2)

    def dot(self, other):
        return self._x * other._x + self._y * other._y

    def __add__(self, other):
        return Vector2(self._x + other._x, self._y + other._y)

    def __sub__(self, other):
        return Vector2(self._x - other._x, self._y - other._y)

    def __str__(self):
        round_x = round(self._x, 6)
        round_y = round(self._y, 6)
        return "{} {}".format(round_x, round_y)

    def __mul__(self, scale):
        return Vector2(self._x * scale, self._y * scale)


for s in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, s.split(','))

    OP1 = Vector2(x1, y1)
    OP2 = Vector2(x2, y2)
    OQ = Vector2(xq, yq)

    P2P1 = OP2 - OP1
    N = P2P1.normalize()

    P1Q = OQ - OP1

    # projection
    dot = P1Q.dot(N)
    P1O = N * dot

    QO = P1O - P1Q
    OR = OP1 + P1O + QO

    print(OR)

Submission status: Accepted

Solution code:
from decimal import Decimal as D
import sys

def naiseki(A,B):
    return A[0]*B[0]+A[1]*B[1]
def scaler(k,A):
    return[k*A[0],k*A[1]]
def size(A):
    return A[0]**2+A[1]**2
def plus(A,B):
    return [A[0]+B[0],A[1]+B[1]]

while True:
    try:
        x1,y1,x2,y2,xq,yq=[D(i) for i in input().split(",")]
        P1P2=[x2-x1,y2-y1]
        P1Q=[xq-x1,yq-y1]
        P1H=scaler(naiseki(P1P2,P1Q)/size(P1P2),P1P2)
        QH=plus(P1H,scaler(-1,P1Q))
        QR=scaler(2,QH)
        OP1=[x1,y1]
        OR=plus(OP1,plus(P1Q,QR))
        print(OR[0],OR[1])
    except EOFError:
        sys.exit()

Submission status: Accepted

Solution code:
# Aizu Problem 0081: Symmetric Point
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def symmetric_point(x1, y1, x2, y2, xq, yq):
    rx = x2 - x1
    ry = y2 - y1
    det = -rx**2 - ry**2
    det_s = rx * (yq - y1) - ry * (xq - x1)
    s = det_s / det
    xr = xq - 2 * s * ry
    yr = yq + 2 * s * rx
    return xr, yr


for line in sys.stdin:
    x1, y1, x2, y2, xq, yq = [float(_) for _ in line.split(',')]
    xr, yr = symmetric_point(x1, y1, x2, y2, xq, yq)
    print("%.6f %.6f" % (xr, yr))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0081

"""
import sys
from sys import stdin
input = stdin.readline



class Point(object):
    epsilon = 1e-10

    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Point(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Point(self.x / other, self.y / other)

    def __lt__(self, other):
        if self.x == other.x:
            return self.y < other.y
        else:
            return self.x < other.x

    def __eq__(self, other):
        from math import fabs
        if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
            return True
        else:
            return False

    def norm(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return sqrt(self.norm())

    def ccw(self, p0, p1):
        # ??????2???(p0, p1)?????????????????????????????????????????¢????????????
        a = Vector(p1 - p0)
        b = Vector(self - p0)
        if Vector.cross(a, b) > Point.epsilon:
            return 1 # 'COUNTER_CLOCKWISE'
        elif Vector.cross(a, b) < -Point.epsilon:
            return -1 # 'CLOCKWISE'
        elif Vector.dot(a, b) < -Point.epsilon:
            return 2 # 'ONLINE_BACK'
        elif a.norm() < b.norm():
            return -2 # 'ONLINE_FRONT'
        else:
            return 0 # 'ON_SEGMENT'

    def project(self, s):
        # ??????(Point)????????????s??????????????????????????????????????§?¨?(?°???±)????±???????
        base = Vector(s.p2 - s.p1)
        a = Vector(self - s.p1)
        r = Vector.dot(a, base)
        r /= base.norm()
        return s.p1 + base * r

    def reflect(self, s):
        # ??????s???????§°?????¨?????????????????¨???????§°??????????????§?¨?(????°?)????±???????
        proj = self.project(s)
        return self + (proj - self)*2

    def distance(self, s):
        # ????????¨??????s????????¢????¨??????????
        if Vector.dot(s.p2-s.p1, self-s.p1) < 0.0:
            return abs(self - s.p1)
        if Vector.dot(s.p1-s.p2, self-s.p2) < 0.0:
            return abs(self - s.p2)
        return abs(Vector.cross(s.p2-s.p1, self-s.p1) / abs(s.p2-s.p1))


class Vector(Point):
    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        elif isinstance(x, Point):
            self.x = x.x
            self.y = x.y
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Vector(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Vector(self.x / other, self.y / other)


    @classmethod
    def dot(cls, a, b):
        return a.x * b.x + a.y * b.y

    @classmethod
    def cross(cls, a, b):
        return a.x * b.y - a.y * b.x

    @classmethod
    def is_orthogonal(cls, a, b):
        return abs(Vector.dot(a, b)) < Vector.epsilon

    @classmethod
    def is_parallel(cls, a, b):
        return abs(Vector.cross(a, b)) < Vector.epsilon


class Segment(object):
    def __init__(self, p1=Point(), p2=Point()):
        if isinstance(p1, Point):
            self.p1 = p1
            self.p2 = p2
        elif isinstance(p1, tuple):
            self.p1 = Point(p1[0], p1[1])
            self.p2 = Point(p2[0], p2[1])

    def intersect(self, s):
        # ????????¨??????????????????????????????????????????????????????
        ans1 = s.p1.ccw(self.p1, self.p2) * s.p2.ccw(self.p1, self.p2)
        ans2 = self.p1.ccw(s.p1, s.p2) * self.p2.ccw(s.p1, s.p2)
        return ans1 <= 0 and ans2 <= 0

    def cross_point(self, s):
        # ????????¨??????????????????????????????????????§?¨?????±???????
        base = s.p2 - s.p1
        d1 = abs(Vector.cross(base, self.p1-s.p1))
        d2 = abs(Vector.cross(base, self.p2-s.p1))
        t = d1 / (d1 + d2)
        return self.p1 + (self.p2 - self.p1) * t

    def distance(self, s):
        # ????????¨?????????????????????????????¢????±???????
        if self.intersect(s):
            return 0.0
        d1 = s.p1.distance(self)
        d2 = s.p2.distance(self)
        d3 = self.p1.distance(s)
        d4 = self.p2.distance(s)
        return min(d1, d2, d3, d4)


    @classmethod
    def is_orthogonal(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_orthogonal(a, b)

    @classmethod
    def is_parallel(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_parallel(a, b)


class Line(Segment):
    pass


class Cirle(object):
    def __init__(self, x, y=Point(), r=1.0):
        if isinstance(x, Point):
            self.c = x
            self.r = y
        elif isinstance(x, tuple):
            self.c = Point(x[0], x[1])
            self.r = r

    def cross_points(self, s):
        if isinstance(s, Segment):
            pr = self.c.project(s)
            e = (s.p2 - s.p1) / abs(s.p2 - s.p1)
            base = sqrt(self.r * self.r - (pr - self.c).norm())
            return pr + e * base, pr - e * base
        elif isinstance(s, Cirle):
            c2 = s
            d = abs(self.c - c2.c)
            a = acos((self.r * self.r + d * d - c2.r * c2.r) / (2 * self.r * d))
            t = atan2(c2.c.y - self.c.y, c2.c.x - self.c.x)
            temp1 = Point(cos(t+a)*self.r, sin(t+a)*self.r)
            temp2 = Point(cos(t-a)*self.r, sin(t-a)*self.r)
            return self.c + temp1, self.c + temp2


def contains(polygon, p):
    n = len(polygon)
    x = False
    for i in range(n):
        a = polygon[i] - p
        b = polygon[(i+1)%n] - p
        if abs(Vector.cross(a, b)) < Point.epsilon and Vector.dot(a, b) < Point.epsilon:
            return 1
        if a.y > b.y:
            temp = a
            a = b
            b = temp
        if a.y < Point.epsilon and Point.epsilon < b.y and Vector.cross(a, b) > Point.epsilon:
            x = not x
    return 2 if x else 0


def main(args):
    for line in sys.stdin:
        x1, y1, x2, y2, xq, yq = map(float, line.split(','))
        p1 = Point(x1, y1)
        p2 = Point(x2, y2)
        q = Point(xq, yq)
        l = Segment(p1, p2)
        result = q.reflect(l)
        print('{:.8f} {:.8f}'.format(result.x, result.y))



if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
while True:
    try:
        x1, y1, x2, y2, xq, yq = map(float, input().split(","))
        if (y2-y1) == 0:
            xr = xq
            yr = 2*y1 - yq
        elif (x2-x1) == 0:
            xr = 2*x1 - xq
            yr = yq
        else:
            a12 = (y2-y1)/(x2-x1)
            aqr = -1/a12
            b12 = y1 - a12*x1
            bqr = yq - aqr*xq
            xm  = -(b12-bqr)/(a12-aqr)
            ym  = aqr*xm + bqr
            xr = 2*xm - xq
            yr = 2*ym - yq
        print(xr, yr)
    except:
        break

Submission status: Accepted

Solution code:
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    x1,y1,x2,y2,xq,yq = [float(i) for i in N[l].split(",")]

    # l: a*x + b*y + c = 0
    a = y2-y1
    b = x1-x2
    c = y1*(x2-x1) - x1*(y2-y1)
    p = a
    q = b
    A = -a*xq - b*yq - 2*c

    r = x2-x1
    s = y2-y1
    B = xq*(x2-x1) + yq*(y2-y1)

    X = (A*s - B*q)/(p*s-r*q)
    Y = (-A*r + B*p)/(p*s - r*q)

    print(X,Y)

Submission status: Accepted

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=-2*(atan2(y-b,x-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x-s*y+a:.6f} {s*x+t*y+b:.6f}')

Submission status: Accepted

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x+s*y+a:.6f} {s*x-t*y+b:.6f}')

Submission status: Accepted

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,e,f=map(float,e.split(','))
 z,w,q=complex(a,b),complex(c,d),complex(e,f)
 z+=(z-w)*(q-z).conjugate()/(z-w).conjugate()
 print(z.real,z.imag)

Submission status: Accepted

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,e,f=map(float,e.split(','))
 z,w,q=complex(a,b),complex(c,d),complex(e,f)
 z+=((z-w)/abs(z-w))**2*(q-z).conjugate()
 print(z.real,z.imag)

Submission status: Accepted

Solution code:
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,e,f=map(float,e.split(','))
 z,w,q=complex(a,b),complex(c,d),complex(e,f)
 w-=z
 z+=(w/abs(w))**2*(q-z).conjugate()
 print(z.real,z.imag)

Submission status: Accepted

Solution code:
import sys
from decimal import Decimal
for l in sys.stdin:
  x1,y1,x2,y2,xq,yq=list(map(Decimal,l.split(",")))
  a=x1-x2
  b=y1-y2
  c=xq-2*x1
  d=yq-2*y1
  e=yq-y1
  X=(xq*a**2-c*b**2+2*e*a*b)/(a**2+b**2)
  try:
    Y=b/a*(X+c)-d
  except:
    Y=-a/b*(X-xq)+yq
  print(" ".join(["{:.6f}".format(i) for i in [X,Y]]))

Submission status: Accepted

Solution code:
# AOJ 0081 A Symmetric Point
# Python3 2018.6.17 bal4u

def dot(a, b):
	return a.real*b.real + a.imag*b.imag
	
def norm(a):
	return a.real**2 + a.imag**2
	
def project(line, p):
	base = line[1]-line[0]
	r = dot(p-line[0], base) / norm(base)
	return line[0] + base*r
	
def symmetric_Point(line, p):
	return p + 2*(project(line, p)-p)

while True:
	try: p = list(map(float, input().split(',')))
	except: break
	
	line = []
	line.append(complex(p[0], p[1]))
	line.append(complex(p[2], p[3]))
	pp = complex(p[4], p[5])
	qq = symmetric_Point(line, pp)
	print(qq.real, qq.imag)

Submission status: Accepted

Solution code:
def dot(a, b):
	return a.real*b.real + a.imag*b.imag
	
def norm(a):
	return a.real**2 + a.imag**2
	
def project(line, p):
	base = line[1]-line[0]
	r = dot(p-line[0], base) / norm(base)
	return line[0] + base*r
	
def symmetric_Point(line, p):
	return p + 2*(project(line, p)-p)

while True:
	try: p = list(map(float, input().split(',')))
	except: break
	
	line = []
	line.append(complex(p[0], p[1]))
	line.append(complex(p[2], p[3]))
	pp = complex(p[4], p[5])
	qq = symmetric_Point(line, pp)
	print(qq.real, qq.imag)

Submission status: Accepted

Solution code:
def vec(s,t):
    return [t[0]-s[0],t[1]-s[1]]

def dot(a,b):
    return a[0]*b[0]+a[1]*b[1]

def scalsquared(a):
    return (a[0]**2+a[1]**2)

def project(p,a,b):
    k = dot(vec(a,p),vec(a,b)) / scalsquared(vec(a,b))
    return [a[0]+k*(b[0]-a[0]), a[1]+k*(b[1]-a[1])]

def symmetrical_point(p,q):
    return [p[0]+2*(q[0]-p[0]), p[1]+2*(q[1]-p[1])]

while True:
    try:
        tmp = [float(x) for x in input().split(',')]
        p1 = [tmp[0],tmp[1]]
        p2 = [tmp[2],tmp[3]]
        q = [tmp[4],tmp[5]]
        r = symmetrical_point(q,project(q,p1,p2))
        print(r[0], r[1])
    except:
        break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
    x1,y1,x2,y2,xq,yq=map(float,line.strip().split(","))
    if x1==x2:
        x,y=-xq+2*x1,yq
    elif y1==y2:
        x,y=xq,-yq+2*y1
    else:
        m=(y1-y2)/(x1-x2)
        n=-m*x1+y1
        x=(2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1)
        y=(xq-x)/m+yq
    print "{:.6f} {:.6f}".format(x+0,y+0)

Submission status: Accepted

Solution code:
while True:
    try:
        x1,y1,x2,y2,xq,yq=map(float,raw_input().split(","))
    except EOFError:
        break
    try:
        m=(y2-y1)/(x2-x1)
        y=(yq*(m*m-1)+2*m*xq+2*(y2-m*x2))/(1+m*m)
        x=m*yq+xq-m*y
    except ZeroDivisionError:
        x=-xq
        y=yq
    print x,y