QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#431344#8674. Riddle of the SphinxPHarrWA 1ms3912kbC++201.9kb2024-06-05 13:14:002024-06-05 13:14:01

Judging History

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

  • [2024-06-05 13:14:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-06-05 13:14:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define double long double

const double eps=1e-8;
int n = 3;
bool gauss(vector<vector<double>> &a){
	double del = 0;
    for(int i=1;i<=n;i++){
        int k=i;
        for(int j=i+1;j<=n;j++)if(fabs(a[j][i])>fabs(a[k][i]))k=j;
        if(fabs(del=a[k][i])<eps)return 0;
        for(int j=i;j<=n+1;j++)swap(a[i][j],a[k][j]);
        for(int j=i;j<=n+1;j++)a[i][j]/=del;
        for(k=1;k<=n;k++)if(k!=i){
            del=a[k][i];
            for(int j=i;j<=n+1;j++)a[k][j]-=a[i][j]*del;
        }
    }
    return 1;
}

int main(){
	vector<double> ans(5);
	cout << "0 0 1" << endl;
	cin >> ans[0];
	cout << "0 1 0" << endl;
	cin >> ans[1];
	cout << "1 0 0" << endl;
	cin >> ans[2];
	cout << "1 0 1" << endl;
	cin >> ans[3];
	cout << "0 1 1" << endl;
	cin >> ans[4];

	map<array<int,3>,int> mp;

	vector<vector<double>> a(5,vector<double>(5));
	vector<vector<double>> c(5,vector<double>(5));
	c[0] = vector{(double)0.0,(double)0.0,(double)0.0,(double)1.0,ans[0]};
	c[1] = vector{(double)0.0,(double)0.0,(double)1.0,(double)0.0,ans[1]};
	c[2] = vector{(double)0.0,(double)1.0,(double)0.0,(double)0.0,ans[2]};
	c[3] = vector{(double)0.0,(double)1.0,(double)0.0,(double)1.0,ans[3]};
	c[4] = vector{(double)0.0,(double)0.0,(double)1.0,(double)1.0,ans[4]};

	for (int i = 0;i < 5;i++){
		for (int j = i + 1;j < 5;j++){
			for (int k = j + 1;k < 5;k++){
				a[1] = c[i];
				a[2] = c[j];
				a[3] = c[k];
				if(gauss(a)){
					double x = a[1][4],y = a[2][4],q = a[3][4];
					if (x < 0 || y < 0 || q < 0) break;
					for (int z = 0;z < 5;z++){
						if (z == i || z == j || z == k) continue;
						if(abs(x * c[z][1] + y * c[z][2] + q * c[z][3] - c[z][4]) < eps){
							cout << x << " " << y << " " << q << endl;				
							return 0;
						}
					}
				}
			}
		}
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

3
2
1
4
5

output:

0 0 1
0 1 0
1 0 0
1 0 1
0 1 1
1 2 3

result:

ok correct!

Test #2:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

1
1
9998
9999
2

output:

0 0 1
0 1 0
1 0 0
1 0 1
0 1 1
9998 1 1

result:

ok correct!

Test #3:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

3333
3333
3333
6666
6666

output:

0 0 1
0 1 0
1 0 0
1 0 1
0 1 1
3333 3333 3333

result:

ok correct!

Test #4:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

711
503
893
1605
1215

output:

0 0 1
0 1 0
1 0 0
1 0 1
0 1 1
893 503 712

result:

ok correct!

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3912kb

input:

947
365
868
1815
1314

output:

0 0 1
0 1 0
1 0 0
1 0 1
0 1 1
868 365 947

result:

wrong answer read