Problem:
Problem A:
Lost in Space
William Robinson was completely puzzled in the music room; he could not find his triangle in
his bag. He was sure that he had prepared it the night before. He remembered its clank when
he had stepped on the school bus early that morning. No, not in his dream. His triangle was
quite unique: no two sides had the same length, which made his favorite peculiar jingle. He
insisted to the music teacher, Mr. Smith, that his triangle had probably been stolen by those
aliens and thrown away into deep space.
Your mission is to help Will find his triangle in space. His triangle has been made invisible by the
aliens, but candidate positions of its vertices are somehow known. You have to tell which three
of them make his triangle. Having gone through worm-holes, the triangle may have changed its
size. However, even in that case, all the sides are known to be enlarged or shrunk equally, that
is, the transformed triangle is
similar
to the original.
Input
The very first line of the input has an integer which is the number of data sets. Each data set
gives data for one incident such as that of Will’s. At least one and at most ten data sets are
given.
The first line of each data set contains three decimals that give lengths of the sides of the original
triangle, measured in centimeters. Three vertices of the original triangle are named P, Q, and
R. Three decimals given in the first line correspond to the lengths of sides QR, RP, and PQ, in
this order. They are separated by one or more space characters.
The second line of a data set has an integer which is the number of points in space to be
considered as candidates for vertices. At least three and at most thirty points are considered.
The rest of the data set are lines containing coordinates of candidate points, in light years. Each
line has three decimals, corresponding to x, y, and z coordinates, separated by one or more space
characters. Points are numbered in the order of their appearances, starting from one.
Among all the triangles formed by three of the given points, only one of them is
similar
to the
original, that is, ratios of the lengths of any two sides are equal to the corresponding ratios of
the original allowing an error of less than 0.01 percent. Other triangles have some of the ratios
different from the original by at least 0.1 percent.
The origin of the coordinate system is not the center of the earth but the center of our galaxy.
Note that negative coordinate values may appear here. As they are all within or close to our galaxy, coordinate values are less than one hundred thousand light years. You don’t have to
take relativistic effects into account, i.e., you may assume that we are in a Euclidean space. You
may also assume in your calculation that one light year is equal to 9.461 × 10
12
kilometers.
A succeeding data set, if any, starts from the line immediately following the last line of the
preceding data set.
Output
For each data set, one line should be output. That li
...(truncated)

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <valarray>
#include <cmath>

double calc(valarray<double> p1, valarray<double> p2) {
    double res = 0.0;
    REP (i, 0, 3) {
        res += pow(p1[i] - p2[i], 2);
    }
    return sqrt(res);
}

void subMain() {
    valarray<double> len(3);
    REP(i, 0, 3) {
        cin >> len[i];
    }
    int n;
    cin >> n;
    vector<valarray<double>> point(n, valarray<double>(3));
    REP(i, 0, n) {
        REP(j, 0, 3) {
            cin >> point[i][j];
        }
    }
    REP(i, 0, n) {
        REP(j, 0, n) {
            REP(k, 0, n) {
                if (i == j || j == k || k == i) continue;
                valarray<double> res = {
                    calc(point[i], point[j]),
                    calc(point[j], point[k]),
                    calc(point[k], point[i]),
                };
                res /= len;
                double eps = 1e-3;
                if (abs(res[0] - res[1]) <= eps && abs(res[0] - res[2]) <= eps && abs(res[1] - res[2]) <= eps) {
                    cout << k + 1 << " " << i + 1 << " " << j + 1 << endl;
                    return;
                }
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    REP(t, 0, T) {
        subMain();
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3284
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

struct P{
  double x, y, z;
  P():x(0), y(0), z(0){}
  P(double x, double y, double z):x(x), y(y), z(z){}
  P operator+(const P& b)const{
    P res;
    res.x = x + b.x;
    res.y = y + b.y;
    res.z = z + b.z;
    return res;
  }
  P operator-(const P& b)const{
    P res;
    res.x = x - b.x;
    res.y = y - b.y;
    res.z = z - b.z;
    return res;
  }
  bool operator<(const P& b)const{
    if(x == b.x)
      if(y == b.y)
        return z < b.z;
      else
        return y < b.y;
    else
      return x < b.x;
  }
};

bool eq(double a, double b){
  return abs(a-b) < 0.0001;
}

// Experimence
int main(void){
  int T; cin >> T;
  while(T--){
    double QR, RP, PQ; cin >> QR >> RP >> PQ;
    double P_arg = acos((PQ*PQ+RP*RP-QR*QR) / (2*PQ*RP));
    double Q_arg = acos((PQ*PQ+QR*QR-RP*RP) / (2*PQ*QR));
    double R_arg = acos((QR*QR+RP*RP-PQ*PQ) / (2*QR*RP));
    int N; cin >> N;
    vector<P> points(N);
    for(int i = 0; i < N; i++){
      cin >> points[i].x >> points[i].y >> points[i].z;
    }
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        for(int k = 0; k < N; k++){
          if(i == j || j == k || i == k) continue;
          vector<P> triangle(3);
          triangle[0] = points[i];
          triangle[1] = points[j];
          triangle[2] = points[k];

          //do{
            vector<double> edge(3);
            for(int edge_idx = 0; edge_idx < 3; edge_idx++){
              P subtract = triangle[edge_idx%3] - triangle[(edge_idx+1)%3];
              edge[edge_idx] = sqrt(subtract.x*subtract.x + subtract.y*subtract.y + subtract.z*subtract.z);
            }
            double arg1, arg2, arg3;
            arg1 = acos((edge[0]*edge[0]+edge[2]*edge[2]-edge[1]*edge[1]) / (2*edge[0]*edge[2]));
            arg2 = acos((edge[0]*edge[0]+edge[1]*edge[1]-edge[2]*edge[2]) / (2*edge[0]*edge[1]));
            arg3 = acos((edge[1]*edge[1]+edge[2]*edge[2]-edge[0]*edge[0]) / (2*edge[1]*edge[2]));
            //DEBUG
            if(eq(P_arg, arg1) && eq(Q_arg, arg2) && eq(R_arg, arg3)){
              cout << i+1 << " " << j+1 << " " << k+1 << endl;
              i = N; j = N; k = N;
            }
          //}while(next_permutation(triangle.begin(), triangle.end()));

          //cout << i << j << k << endl;
        }
      }
    }
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3372
final_rank: 20

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-2;
const int inf=1e8;
int main(){
	int q;
	cin>>q;
	while(q--){
		double x,y,z;
		cin>>x>>y>>z;
		int n;
		cin>>n;
		vector<vector<double> >in(n,vector<double>(3));
		rep(i,n)rep(j,3)cin>>in[i][j];
		rep(i,n)rep(j,n)rep(k,n)if(i!=j&&j!=k&&k!=i){
			double a=hypot(hypot(in[i][0]-in[j][0],in[i][1]-in[j][1]),in[i][2]-in[j][2]);
			double b=hypot(hypot(in[k][0]-in[j][0],in[k][1]-in[j][1]),in[k][2]-in[j][2]);
			double c=hypot(hypot(in[i][0]-in[k][0],in[i][1]-in[k][1]),in[i][2]-in[k][2]);
			double t=a/x;
			if(abs(x*t-a)<EPS&&abs(y*t-b)<EPS&&abs(z*t-c)<EPS)cout<<k+1<<" "<<i+1<<" "<<j+1<<endl;
		}
	}
}
accuracy: 1
time_ms: 20
memory_kb: 1268
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=40;
double x[mx],y[mx],z[mx];
const double eps=1e-4;
double d(int i,int j){
   return sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)+pow(z[i]-z[j],2));
}
bool eq(double x,double y){
   return fabs(x-y)<eps;
}
int main(){
   int t,n;
   scanf("%d",&t);
   double qr,rp,pq;
   while(t--){
      scanf("%lf %lf %lf",&qr,&rp,&pq);
      scanf("%d",&n);
      for(int i=0;i<n;i++){
         scanf("%lf %lf %lf",x+i,y+i,z+i);
      }
      int p,q,r;
      for(int i=0;i<n;i++){
         for(int j=0;j<n;j++) if(j!=i){
            for(int k=0;k<n;k++) if(k!=i && k!=j){
               double l1=d(i,j);
               double l2=d(j,k);
               double l3=d(k,i);
               double r1=l1/qr;
               double r2=l2/rp;
               double r3=l3/pq;
               if(eq(r1,r2)&&eq(r1,r3)&&eq(r2,r3)){
                  q=i,r=j,p=k;   
               }
            }
         }
      }
      printf("%d %d %d\n",p+1,q+1,r+1);
   }
   return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1228
final_rank: 7

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define EPS 1e-7
#define equals(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y,z;

  double getDist(const Point &p){
    return sqrt(pow(x-p.x,2)+pow(y-p.y,2)+pow(z-p.z,2));
  }
};

int main(){
  int Tc,N;
  double QR,RP,PQ;
  cin >> Tc;
  while(Tc--){
    cin >> QR >> RP >> PQ >> N;
    Point p[N];
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].x >> p[i].y >> p[i].z;
    }
    double qr,rp,pq;
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){ continue; }
        for(int k = 0 ; k < N ; k++){
          if(i == k || j == k){ continue; }
          qr = p[j].getDist(p[k]);
          rp = p[k].getDist(p[i]);
          pq = p[i].getDist(p[j]);
          if(equals(QR/qr,RP/rp) && equals(RP/rp,PQ/pq)){
            cout << i+1 << " " << j+1 << " " << k+1 << endl;
            goto end;
          }
        }
      }
    }
  end:;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1236
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;

const double EPS = 0.05;
inline double dis(vector<double> a, vector<double> b){
  double res = 0;
  for(int i=0;i<3;i++)res += (a[i]-b[i])*(a[i]-b[i]);
  return sqrt(res);
}

int main(){
  int casenum;
  cin >> casenum;
  while(casenum--){
    double qr,rp,pq;
    cin >> qr >> rp >> pq;
    int n;
    cin >> n;
    vector< vector<double> > vp(n,vector<double>(3));
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++)cin >> vp[i][j];
    }

    bool f = true;
    for(int i=0;f && i<n;i++){
      for(int j=0;f && j<n;j++){
	if(i==j)continue;
	for(int k=0;f && k<n;k++){
	  if(i==k)continue;

	  double d1 = dis(vp[j],vp[k]), d2 = dis(vp[k],vp[i]), d3 = dis(vp[i],vp[j]);
	  double ratio = d1/qr;
	  if( abs(ratio*rp-d2)<EPS && abs(ratio*pq-d3)<EPS){
	    cout << i+1 << " " << j+1 << " " << k+1 << endl;
	    f = false;
	  }
	}
      }
    }
  }
}
accuracy: 1
time_ms: 30
memory_kb: 1256
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;

struct P {
  double x,y,z;
};

double D(P a, P b) {
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

bool equal(double a, double b) {
  return fabs(a-b)<0.0000001;
}

int main() {
  int T;
  cin >> T;
  while(T--) {
    double l[3];
    for(int i=0; i<3; i++) cin >> l[i];
    int n;
    cin >> n;
    P a[n];
    for(int i=0; i<n; i++) cin >> a[i].x >> a[i].y >> a[i].z;
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	for(int k=0; k<n; k++) {
	  if(i==j || j==k || k==i) continue;
	  double d1=l[2]/D(a[i],a[j]);
	  double d2=l[0]/D(a[j],a[k]);
	  double d3=l[1]/D(a[k],a[i]);
	  if(!equal(d1,d2) || !equal(d1,d3)) continue;
	  cout << i+1 << " " << j+1 << " " << k+1 << endl;
	  goto End;
	}
      }
    }
    End:;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1236
final_rank: 8

code_snippet: #include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef double D;
struct P {
	D x, y, z;
	P(){}
	P(D xx, D yy, D zz):x(xx), y(yy), z(zz){}
};

D dis(P a, P b) {
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

const double EPS = 0.05;

int main()
{
	int N; cin>>N;
	while (N--) {
		D QR, RP, PQ;
		cin>>QR>>RP>>PQ;
		int M; cin>>M;
		vector<P> points;
		
		for (int i=0; i<M; i++) {
			double x, y, z;
			cin>>x>>y>>z;
			points.push_back(P(x, y, z));
		}
		
		for (int p=0; p<M; p++) {
			for (int q=0; q<M; q++) {
				for (int r=0; r<M; r++) {
					if (p!=q && p!=r) {
						D a = dis(points[p], points[q])/PQ;
						D b = dis(points[q], points[r])/QR;
						D c = dis(points[r], points[p])/RP;
						if (fabs(a-b)<EPS && fabs(b-c)<EPS && fabs(c-a)<EPS) {
							cout << (p+1) << " " << (q+1) << " " << (r+1) << endl;
						}
					}
				}
			}
		}
	}
}
accuracy: 1
time_ms: 10
memory_kb: 1248
final_rank: 14

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

inline double sq(double x){
	return x*x;
}

double x[100], y[100], z[100];

double dist(int i, int j){
	return sqrt(sq(x[i] - x[j]) + sq(y[i] - y[j]) + sq(z[i] - z[j]));
}

double EPS = 1e-4;
bool check(double a, double b, double c){
	if (abs(a - b) > EPS) return false;
	if (abs(b - c) > EPS) return false;
	if (abs(c - a) > EPS) return false;
	return true;
}

int main(){
	int T;
	cin >> T;
	while (T--){
		double a, b, c;
		cin >> a >> b >> c;
		int n;
		cin >> n;
		rep(i, n) cin >> x[i] >> y[i] >> z[i];

		rep(i, n) rep(j, n) rep(k, n){
			if (i == j && j == k) continue;
			if (check(dist(j, k) / a, dist(k, i) / b, dist(i, j) / c)){
				cout << i+1 << " " << j+1 << " " << k+1 << endl;
			}
		}
	}

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1236
final_rank: 8

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

const double eps = 5e-3;

struct point {
  double x,y,z;
  point(){}
  point(double x, double y, double z):x(x),y(y),z(z){}
  point operator-(const point &t){
    return point(x-t.x,y-t.y,z-t.z);
  }
};

double abs(const point &a){
  return sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
}

bool eq( double a, double b){
  return abs(a/b-b/a)<0.0001;
}

int main()
{
  int T;
  cin >> T;
  for(int tc=0;tc<T;++tc){
    int n;
    double l[3];
    vector<point> vp;

    for(int i = 0; i < 3; ++i){
      //  QR , RP , PQ
      cin >> l[i];
    }

    cin >> n;
    for(int i = 0; i < n; ++i){
      point p; cin >> p.x >> p.y >> p.z;
      vp.push_back( p );
    }

    for(int a = 0; a < n; ++a){
      
      for(int b = 0; b < n; ++b){
        if( a == b ) continue;
        
        for(int c = 0; c < n; ++c){
          if( b == c || a == c ) continue;
          
          double tl[3];
          
          tl[0] = abs(vp[a]-vp[b]);
          tl[1] = abs(vp[b]-vp[c]);
          tl[2] = abs(vp[c]-vp[a]);
          if( eq(tl[2]/l[2], tl[1]/l[1]) &&
              eq(tl[2]/l[2], tl[0]/l[0]) ){
            cout << c+1 << ' ' << a+1 << ' ' << b+1 << endl;
          }
        }
      }
    }
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1240
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

const double eps = 5e-3;

struct point {
  double x,y,z;
  point(){}
  point(double x, double y, double z):x(x),y(y),z(z){}
  point operator-(const point &t){
    return point(x-t.x,y-t.y,z-t.z);
  }
};

double abs(const point &a){
  return sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
}

bool eq( double a, double b){
  return abs(a/b-b/a)<0.0001;
}

//                       a b c
//                       Q R P
const int possible[3][3] = { {1,1,0},
                             {0,1,1},
                             {1,0,1} };

bool determine(int p[3], int q[3], int depth, pair<int,int> out[3] ){
  if( depth == 3 ){
    for(int i = 0; i < depth; ++i){
      for(int j = i+1; j < depth; ++j){
        if( (out[i].first == out[j].first || out[i].second == out[j].second) ){
          return false;
        }
      }
    }
    return true;
  }
  for(int j = 0; j < 3; ++j){
    for(int k = 0; k < 3; ++k){
      if( possible[p[depth]][j] && possible[q[depth]][k] ){
        out[depth] = make_pair(j,k);
        if( determine(p,q,depth+1,out) ) return true;
      }
    }
  }
  return false;
}

int main()
{
  int T;
  cin >> T;
  for(int tc=0;tc<T;++tc){
    int n;
    pair<double,int> l[3];
    vector<point> vp;

    for(int i = 0; i < 3; ++i){
      //  QR , RP , PQ
      cin >> l[i].first;
      l[i].second = i;
    }
    // sort(l,l+3);

    cin >> n;
    for(int i = 0; i < n; ++i){
      point p; cin >> p.x >> p.y >> p.z;
      vp.push_back( p );
    }

    for(int a = 0; a < n; ++a){
      
      for(int b = 0; b < n; ++b){
        if( a == b ) continue;
        
        for(int c = 0; c < n; ++c){
          if( b == c || a == c ) continue;
          
          pair<double,int> tl[3];
          
          tl[0] = make_pair(abs(vp[a]-vp[b]),0);
          tl[1] = make_pair(abs(vp[b]-vp[c]),1);
          tl[2] = make_pair(abs(vp[c]-vp[a]),2);
          // sort(tl,tl+3);
          
          if( eq( tl[2].first / l[2].first, tl[1].first / l[1].first ) &&
              eq( tl[2].first / l[2].first, tl[0].first / l[0].first) ) {

            cout << c+1 << ' ' << a+1 << ' ' << b+1 << endl;
            /*
            int pp[3] = { l[2].second, l[1].second, l[0].second};
            int qq[3] = {tl[2].second,tl[1].second,tl[0].second};
            pair<int,int> res[3];
            determine(pp,qq,0,res);

            sort(res,res+3);

            cout << a << ' ' << b << ' ' << c << endl;
            for(int i = 0; i < 3; ++i){
              cout << res[i].first << ' ' << res[i].second << endl;
            }
            swap(res[0],res[2]);
            swap(res[1],res[2]);

            int id[3] = {a,b,c};
            for(int i = 0; i < 3; ++i){
              if( i ) cout << ' ';
              cout << 1+id[res[i].second];
            }
            cout << endl;
            */
          }
        }
      }
    }
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1240
final_rank: 12

code_snippet: //12
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

struct P{
  double x,y,z;
  double sq(double a){
    return a*a;
  }
  double ds(P a){
    return sqrt(sq(x-a.x)+sq(y-a.y)+sq(z-a.z));
  }
};

int main(){
  int t;
  cin>>t;
  while(t--){
    double qr,rp,pq;
    int np;
    cin>>qr>>rp>>pq>>np;
    P ps[30];
    for(int i=0;i<np;i++){
      cin>>ps[i].x>>ps[i].y>>ps[i].z;
    }
    double e=1<<30;
    int p,q,r;
    for(int i=0;i<np;i++){
      for(int j=0;j<np;j++){
	for(int k=0;k<np;k++){
	  double cqr,crp,cpq;
	  cqr=ps[j].ds(ps[k])/qr;
	  crp=ps[k].ds(ps[i])/rp;
	  cpq=ps[i].ds(ps[j])/pq;
	  cqr/=crp;
	  cpq/=crp;
	  double me=max(fabs(cqr-1),fabs(cpq-1));
	  if(min(cqr,min(crp,cpq))>0&&me<e){
	    e=me;
	    p=i;
	    q=j;
	    r=k;
	  }
	}
      }
    }
    cout<<p+1<<' '<<q+1<<' '<<r+1<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1236
final_rank: 8

code_snippet: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-4;
const int MOD = 1000000007;
struct P{
  double x, y, z;
};
double dist(double x, double y, double z){
  return sqrt(x*x + y*y + z*z);
}
double dist2(P p, P q){
  return dist(p.x-q.x, p.y-q.y, p.z-q.z);
}

int main(){
  int T; cin>>T;
  while(T--){
    double target[3];
    REP(i, 3) cin>>target[i];
    int N; cin>>N;
    vector<P> points(N);
    REP(i, N){
      cin>>points[i].x>>points[i].y>>points[i].z;
    }
    REP(i, N)REP(j, N)REP(k, N)if(i != j && j != k && k != i){
      double tri[3];
      tri[0] = dist2(points[i], points[j]);
      tri[1] = dist2(points[j], points[k]);
      tri[2] = dist2(points[k], points[i]);
      bool ok = true;
      REP(idx, 3){
        if(abs(tri[(idx+1)%3]/tri[idx] - target[(idx+1)%3]/target[idx]) > EPS){
          ok = false;
        }
      }
      if(ok) printf("%d %d %d\n", k+1, i+1, j+1);
    }
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include<stdio.h>
#include<math.h>
struct P{double x,y,z;};
#define S(x) ((x)*(x))
double D(P a,P b){return sqrt(S(a.x-b.x)+S(a.y-b.y)+S(a.z-b.z));}
int G(double x,double y)
{
	return (x*0.9998<=y&&y<=x*1.0002);
}
int F(P p,P q)
{
	double c=q.x/p.x,d=q.y/p.y,e=q.z/p.z;
	return G(c,d)&&G(c,e);
}
int main()
{
	P p,a[100];
	int T,n,i,j,k;
	for(scanf("%d",&T);T--;)
	{
		scanf("%lf%lf%lf%d",&p.x,&p.y,&p.z,&n);
		for(i=0;i<n;++i)scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].z);
		for(i=0;i<n;++i)for(j=0;j<n;++j)for(k=0;k<n;++k)
		{
			if(i==j||j==k)continue;
			P x={D(a[j],a[k]),D(a[k],a[i]),D(a[i],a[j])};
			if(F(p,x))printf("%d %d %d\n",i+1,j+1,k+1);
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

double x[30];
double y[30];
double z[30];

inline double dbl(double i){ return i * i; }

double dist(int i, int j){
  return sqrt( dbl(x[i] - x[j]) +
	       dbl(y[i] - y[j]) +
	       dbl(z[i] - z[j]) );
}

int main(){
  int cc;
  double qr, rp, pq;
  scanf("%d", &cc);

  while(cc --> 0){
    int n; 
    scanf("%lf%lf%lf", &qr, &rp, &pq);
    scanf("%d", &n);
    REP(i,n) scanf("%lf%lf%lf",x+i,y+i,z+i);
    vector<int> v(n);
    v[n-1] = v[n-2] = v[n-3] = 1;
    do{
      vector<int> pqr;
      REP(i,n) if(v[i]) pqr.push_back(i);

      do{
	const int p = pqr[0];
	const int q = pqr[1];
	const int r = pqr[2];
	const double e1 = dist(p, q) / pq;
	const double e2 = dist(q, r) / qr;
	const double e3 = dist(r, p) / rp;
	const double eps = 1e-5;

	if(std::abs(e1 - e2) < e1 * eps &&
	   std::abs(e2 - e3) < e2 * eps &&
	   std::abs(e3 - e1) < e3 * eps){
	  printf("%d %d %d\n", p + 1, q + 1, r + 1);
	  goto next;
	}
      }while(next_permutation(pqr.begin(), pqr.end()));
    }while(next_permutation(v.begin(), v.end()));
  next:;
  }

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> P;

struct Triangle{
    double qr,rp,pq;
};

struct Point{
    double x,y,z;
};

#define EPS (0.05)
#define EQ(a,b) (abs((a)-(b))<EPS)

int main(){

    int t;
    cin>>t;
    while(t--){
        Point p[100];
        int n;
        Triangle org;
        cin>>org.qr>>org.rp>>org.pq;
        cin>>n;
        for(int i = 0; i < n; i++)
            cin>>p[i].x>>p[i].y>>p[i].z;
        // ツ三ツ点ツ選ツづアツづ堕環篠猟チツェツッツク
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    if(i==j||j==k||k==i)
                        continue;
                    // ツ選ツづアツつセツ点ツづ三ツ陛督づーツ催ャツづゥ
                    double pq=sqrt(pow(p[i].x-p[j].x,2)+pow(p[i].y-p[j].y,2)+pow(p[i].z-p[j].z,2));
                    double qr=sqrt(pow(p[j].x-p[k].x,2)+pow(p[j].y-p[k].y,2)+pow(p[j].z-p[k].z,2));
                    double rp=sqrt(pow(p[k].x-p[i].x,2)+pow(p[k].y-p[i].y,2)+pow(p[k].z-p[i].z,2));
                    // ツ三ツ陛督づ個氾、ツ猟ヲツづーツ確ツ認
                    double pqPer=pq/org.pq;
                    double qrPer=qr/org.qr;
                    double rpPer=rp/org.rp;
                    // match
                    if(EQ(pqPer,qrPer)&&EQ(qrPer,rpPer))
                        cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
                }
            }
        }
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;

#define EPS 0.0002

struct Point{double x,y,z;};
double getDistance(Point p1,Point p2)
{
  return sqrt(pow(p1.x-p2.x,2.0)+pow(p1.y-p2.y,2.0)+pow(p1.z-p2.z,2.0));
}

int main()
{
  int n,m,P,Q,R;
  double original[3],x,y,z;
  int i,j,k,t;
  cin>>n;
  while(n-->0){
    for(i=0;i<3;i++)cin>>original[i];

    cin>>m;
    vector<Point>v(m);
    for(i=0;i<m;i++){
      cin>>x>>y>>z;
      Point p={x,y,z};
      v[i]=p;
    }

    P=0;
    for(i=0;i<m;i++){
      for(j=0;j<m;j++){
	if(i==j)continue;
	for(k=0;k<m;k++){
	  if(i==k||j==k)continue;
	  double d[3]={getDistance(v[j],v[k]),getDistance(v[k],v[i]),getDistance(v[i],v[j])};
	  bool ok=true;
	  for(t=0;t<3;t++){
	    if(original[t]/original[(t+1)%3]-d[t]/d[(t+1)%3]>EPS)ok=false;
	  }
	  if(ok){
	    P=i+1;
	    Q=j+1;
	    R=k+1;
	  }
	  if(P)break;
	}
	if(P)break;
      }
      if(P)break;
    }

    cout<<P<<" "<<Q<<" "<<R<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;

#define EPS 0.0002

struct Point{double x,y,z;};
double getDistance(Point p1,Point p2)
{
  return sqrt(pow(p1.x-p2.x,2.0)+pow(p1.y-p2.y,2.0)+pow(p1.z-p2.z,2.0));
}

int main()
{
  int n,m,P,Q,R;
  double original[3],x,y,z;
  int i,j,k;
  cin>>n;
  while(n-->0){
    for(i=0;i<3;i++)cin>>original[i];

    cin>>m;
    vector<Point>v(m);
    for(i=0;i<m;i++){
      cin>>x>>y>>z;
      Point p={x,y,z};
      v[i]=p;
    }

    P=0;
    for(i=0;i<m;i++){
      for(j=0;j<m;j++){
	if(i==j)continue;
	for(k=0;k<m;k++){
	  if(i==k||j==k)continue;
	  Point p[3]={v[i],v[j],v[k]};
	  bool ok=true;
	  double d[3]={getDistance(p[1],p[2]),getDistance(p[2],p[0]),getDistance(p[0],p[1])};
	  for(int s=0;s<3;s++){
	    if(original[s]/original[(s+1)%3]-d[s]/d[(s+1)%3]>EPS)ok=false;
	  }
	  if(ok){
	    P=i+1;
	    Q=j+1;
	    R=k+1;
	  }
	  if(P)break;
	}
	if(P)break;
      }
      if(P)break;
    }

    cout<<P<<" "<<Q<<" "<<R<<endl;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 968
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;

#define EPS 0.0002

struct Point{double x,y,z;};
double getDistance(Point p1,Point p2)
{
  return sqrt(pow(p1.x-p2.x,2.0)+pow(p1.y-p2.y,2.0)+pow(p1.z-p2.z,2.0));
}

int main()
{
  int n,m,P,Q,R;
  double original[3],x,y,z;
  int i,j,k,l;
  cin>>n;
  while(n-->0){
    for(i=0;i<3;i++)cin>>original[i];

    cin>>m;
    vector<Point>v(m);
    for(i=0;i<m;i++){
      cin>>x>>y>>z;
      Point p={x,y,z};
      v[i]=p;
    }

    P=0;
    for(i=0;i<m;i++){
      for(j=0;j<m;j++){
	if(i==j)continue;
	for(k=0;k<m;k++){
	  if(i==k||j==k)continue;
	  Point p[3]={v[i],v[j],v[k]};
	  bool ok=true;
	  double d[3]={getDistance(p[1],p[2]),getDistance(p[2],p[0]),getDistance(p[0],p[1])};
	  for(int s=0;s<3;s++){
	    for(int t=0;t<3;t++){
	      if(original[s]/original[t]-d[s]/d[t]>EPS)ok=false;
	    }
	  }
	  if(ok){
	    P=i+1;
	    Q=j+1;
	    R=k+1;
	  }
	  if(P)break;
	}
	if(P)break;
      }
      if(P)break;
    }

    cout<<P<<" "<<Q<<" "<<R<<endl;
  }
}
accuracy: 1
time_ms: 30
memory_kb: 968
final_rank: 18

code_snippet: #define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-4;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

long double QR, RP, PQ;
long double x[100];
long double y[100];
long double z[100];
long double dist(int i, int j){
	long double dx = abs(x[i] - x[j]);
	long double dy = abs(y[i] - y[j]);
	long double dz = abs(z[i] - z[j]);
	return sqrt(dx * dx + dy * dy + dz * dz);
}

int main(){
	int T;
	int n;
	long double pq, qr, rp;
	cin >> T;
	rep(t, T){
		cin >> QR >> RP >> PQ;
		cin >> n;
		rep(i, n){
			cin >> x[i] >> y[i] >> z[i];
		}
	
		rep(i, n) rep(j, n) rep(k, n){
			if(i == j || j == k || k == i) continue;
			pq = dist(i, j);
			qr = dist(j, k);
			rp = dist(k, i);
			long double ratio = pq / PQ;
			if(abs(ratio - qr / QR) < EPS && abs(ratio - rp / RP) < EPS){
				cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;
			}
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1