You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const double eps = 1e-6;
double x1[N], x2[N];
int y[N];
int sign(double x)
{
if (x < -eps) return -1;
if (x > eps) return 1;
return 0;
}
int main()
{
uniform_real_distribution<double> unif(-1e5, 1e5);
default_random_engine re(time(0));
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lf%lf%d", x1 + i, x2 + i, y + i);
bool flag = false;
for (int t = 0; t < 1000 && !flag; t++)
{
flag = true;
double p1 = unif(re), p2 = unif(re);
for (int i = 0; i < n; i++)
if (sign(x1[i] * p1 + x2[i] * p2) != y[i])
flag = false;
if (flag)
break;
}
puts(flag ? "Successful!" : "Infinite loop!");
}
return 0;
}