QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217390#6620. Linear Fractional TransformationzhuibaoWA 207ms3972kbC++202.3kb2023-10-16 20:27:142023-10-16 20:27:14

Judging History

你现在查看的是最新测评结果

  • [2023-10-16 20:27:14]
  • 评测
  • 测评结果:WA
  • 用时:207ms
  • 内存:3972kb
  • [2023-10-16 20:27:14]
  • 提交

answer

#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll>pi; typedef complex<double>cx;
#define int ll
#define X first
#define Y second
#define fer(i,a,n) for(int i=a;i<=n;i++)
#define ref(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,x) memset(a,x,sizeof a)
#define ac IO;int t;cin>>t;while(t--)solve()
#define AC signed main(){IO;solve();}
#define NO {cout<<"NO"<<endl;return;}
#define YES {cout<<"YES"<<endl;return;}
#define re(a) {cout<<a<<endl;return;}
#define all(v) v.begin(),v.end()
//ofstream fout("1.out", ios::out);
//ifstream fin("1.in", ios::in);
//#define cout fout
//#define cin fin
//--------------------瑞神神中神--------------------

const double eps=1e-6;
complex<double>a[5][5],z[5],w[5];
int equ=3,var=3;

double ffabs(complex<double>x)
{
    return x.real()*x.real()+x.imag()*x.imag();
}

int gauss(){
    int i,j,k,col,max_r;
    for(k=0,col=0;k<equ&&col<var;k++,col++){
        max_r = k;
        for(i=k+1;i<equ;i++){
            if(ffabs(a[i][col])> ffabs(a[max_r][col]))
                max_r = i;
        }
        if(ffabs(a[max_r][col])<eps) return 0;
        if(k!=max_r){
            swap(a[k],a[max_r]);
        }
        for(j=col+1;j<=var;j++) a[k][j]/=a[k][col];
        a[k][col] = 1;
        for(i=0;i<equ;i++)
            if(i!=k){
                a[i][var] -= a[k][var]*a[i][col];
                for(j=col+1;j<var;j++) a[i][j] -= a[k][j]*a[i][col];
                a[i][col] = 0;
            }
    }
    return 1;
}

void solve()
{
    for(int i=0;i<3;i++)
    {
        double za,zb,wa,wb;
        cin>>za>>zb>>wa>>wb;
        z[i].real(za);z[i].imag(zb);w[i].real(wa);w[i].imag(wb);
        a[i][0]=z[i];a[i][1].real(1);a[i][2]=-w[i];a[i][3]=w[i]*z[i];
    }
    complex<double>z0;
    double za,zb;cin>>za>>zb;
    z0.real(za);z0.imag(zb);
    complex<double>c=(w[0]-w[1])/(z[0]-z[1]);
    complex<double>d=w[0]-(w[0]-w[1])/(z[0]-z[1])*z[0];
    complex<double>ans;
    if(ffabs(c*z[2]+d-w[2])<eps)
    {
        ans=c*z0+d;
    }
    else
    {
        gauss();
        ans=(a[0][3]*z0+a[1][3])/(z0-a[3][3]);
    }
    cout<<setprecision(12)<<ans.real()<<' '<<ans.imag()<<'\n';
}

signed main()
{
    ac;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3972kb

input:

2
-1 0 0 -1
0 1 -1 0
1 0 0 1
0 -1
-1 0 -1 0
0 1 0 -1
1 0 1 0
0 -1

output:

1 0
0 1

result:

ok 4 numbers

Test #2:

score: -100
Wrong Answer
time: 207ms
memory: 3896kb

input:

100000
0 0 -1 1
1 1 1 0
1 0 1 -1
-1 0
-1 -1 -1 1
1 -1 1 -1
-1 0 1 0
-1 -1
-1 -1 0 -1
-1 1 -1 -1
0 -1 0 0
1 1
1 0 0 -1
0 0 0 0
-1 -1 1 0
1 1
-1 -1 0 -1
0 1 1 -1
1 0 -1 -1
1 -1
0 1 1 -1
1 0 1 0
0 -1 0 1
-1 -1
1 1 -1 1
0 0 -1 -1
0 1 0 1
1 0
1 1 1 -1
0 1 -1 -1
1 0 -1 0
1 -1
1 0 -1 1
-1 -1 1 0
0 -1 0 1
0...

output:

2.2 1.4
0.4 -0.2
-2 -4
0.8 -0.6
-1 -0.666666666667
-0.7 -0.1
-1 1
-1.07692307692 0.384615384615
-3 5
0.25 -0.25
0.5 -1
-1.29411764706 -0.823529411765
0.5 -1.5
-2 0
-nan -nan
2 0
-0.8 -0.4
-0.724137931034 1.68965517241
-1.07692307692 1.38461538462
0 1
-1 -1
1.11022302463e-16 -0.5
-1 2
0.588235294118 ...

result:

wrong answer 1st numbers differ - expected: '1.0000000', found: '2.2000000', error = '1.2000000'