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.
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
#define CRP(t, x) const t &x
|
|
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
|
#define FIL(x, v) memset(x, v, sizeof(x))
|
|
#define CLR(x) FIL(x, 0)
|
|
#define NE1(x) FIL(x, -1)
|
|
#define INF(x) FIL(x, 0x3f)
|
|
typedef long long ll, i64;
|
|
const int N = 1e5 + 50;
|
|
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
|
|
struct node
|
|
{
|
|
ll a, b;
|
|
OPL(node, rhs) { return b * rhs.a > a * rhs.b; }
|
|
void neg() { a = -a, b = -b; }
|
|
} p[N];
|
|
struct ans
|
|
{
|
|
ll h, l;
|
|
OPL(ans, rhs) { return h * rhs.l < l * rhs.h; }
|
|
void simp()
|
|
{
|
|
if (h == 0) return void(l = 1);
|
|
if (l < 0) h = -h, l = -l;
|
|
int g = gcd(abs(h), l);
|
|
h /= g, l /= g;
|
|
}
|
|
};
|
|
int main()
|
|
{
|
|
set<ans> S;
|
|
int T, n, c;
|
|
scanf("%d", &T);
|
|
while (T--)
|
|
{
|
|
S.clear();
|
|
scanf("%d%d", &n, &c);
|
|
int suma = 0, sumb = 0;
|
|
for (int i = 1; i <= n; i++)
|
|
scanf("%lld%lld", &p[i].a, &p[i].b), suma -= p[i].a, sumb -= p[i].b;
|
|
p[0] = {1, 100000000ll}, p[n + 1] = {1, -100000000ll};
|
|
sort(p + 1, p + n + 1);
|
|
bool flag = false;
|
|
for (int i = 1; i <= n + 1; i++)
|
|
{
|
|
if (suma == 0)
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
ans cur = {c - sumb, suma};
|
|
cur.simp();
|
|
if (p[i - 1].a * cur.h + p[i - 1].b * cur.l >= 0 && p[i].a * cur.h + p[i].b * cur.l <= 0)
|
|
S.insert(cur);
|
|
suma += p[i].a << 1, sumb += p[i].b << 1;
|
|
}
|
|
if (flag)
|
|
puts("-1");
|
|
else
|
|
{
|
|
printf("%d", (int)S.size());
|
|
for (auto &x : S) printf(" %lld/%lld", x.h, x.l);
|
|
putchar('\n');
|
|
}
|
|
}
|
|
return 0;
|
|
} |