Tue, 06 Aug 2019 15:12:42 +0800
parent
e9144f1124
commit
378666eaf5
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
#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;
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
#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;
|
||||
int a[1005];
|
||||
struct MyStruct
|
||||
{
|
||||
int a[21], n;
|
||||
OPL(MyStruct, rhs)
|
||||
{
|
||||
auto b = rhs.a;
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
if (a[i] - a[i - 1] < b[i] - b[i - 1]) return true;
|
||||
if (a[i] - a[i - 1] > b[i] - b[i - 1]) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} arr[362881];
|
||||
int main()
|
||||
{
|
||||
int T, n, k;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d%d", &n, &k);
|
||||
if (n <= 9)
|
||||
{
|
||||
for (int i = 0; i < n; i++) a[i] = i + 1;
|
||||
int cnt = 0;
|
||||
do
|
||||
{
|
||||
memcpy(arr[cnt].a, a, n << 2);
|
||||
arr[cnt].n = n;
|
||||
cnt++;
|
||||
/*for (int i = 0; i < n; i++)
|
||||
printf("%2d%c", a[i], " \n"[i == n - 1]);
|
||||
printf(" ");
|
||||
for (int i = 1; i < n; i++)
|
||||
printf("%2d%c", a[i] - a[i - 1], " \n"[i == n - 1]);
|
||||
putchar('\n');*/
|
||||
} while (next_permutation(a, a + n));
|
||||
sort(arr, arr + cnt);
|
||||
/*
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
auto a = arr[i].a;
|
||||
for (int i = 0; i < n; i++)
|
||||
printf("%2d%c", a[i], " \n"[i == n - 1]);
|
||||
printf(" ");
|
||||
for (int i = 1; i < n; i++)
|
||||
printf("%2d%c", a[i] - a[i - 1], " \n"[i == n - 1]);
|
||||
putchar('\n');
|
||||
}*/
|
||||
auto a = arr[k - 1].a;
|
||||
for (int i = 0; i < n; i++) printf("%d%c", a[i], " \n"[i == n - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
a[0] = n;
|
||||
for (int i = 1; i < n; i++) a[i] = i;
|
||||
int cnt = 0;
|
||||
do
|
||||
{
|
||||
//memcpy(arr[cnt].a, a, n << 2);
|
||||
//arr[cnt].n = n;
|
||||
cnt++;
|
||||
if (cnt == k) break;
|
||||
} while (next_permutation(a, a + n));
|
||||
for (int i = 0; i < n; i++) printf("%d%c", a[i], " \n"[i == n - 1]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,4 @@
|
||||
s = 'a' * int(1e6)
|
||||
print(30)
|
||||
for _ in range(30):
|
||||
print(s)
|
||||
@ -0,0 +1,40 @@
|
||||
#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 = 1000;
|
||||
int a[N], n, x, y, cnt;
|
||||
bool b[N];
|
||||
void dfs(int st)
|
||||
{
|
||||
if (st == n)
|
||||
{
|
||||
for (int i = 0; i < n; i++) printf("%2d%c", a[i], " \n"[i == n - 1]);
|
||||
cnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (st == 0)
|
||||
b[a[st] = x] = true, dfs(st + 1), b[x] = false;
|
||||
else if (st == n - 1)
|
||||
{
|
||||
if (!b[y] && abs(y - a[st - 1]) <= 2) b[a[st] = y] = true, dfs(st + 1), b[y] = false;
|
||||
}
|
||||
else
|
||||
for (int i = 1; i <= n; i++)
|
||||
if (i != x && i != y && !b[i] && abs(i - a[st - 1]) <= 2)
|
||||
b[a[st] = i] = true, dfs(st + 1), b[i] = false;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for (; ~scanf("%d%d%d", &n, &x, &y); printf(":%d\n", cnt)) dfs(cnt = 0);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#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;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32")
|
||||
add_executable(01 01.cpp)
|
||||
add_executable(02 02.cpp)
|
||||
add_executable(03 03.cpp)
|
||||
add_executable(04 04.cpp)
|
||||
add_executable(05 05.cpp)
|
||||
add_executable(06 06.cpp)
|
||||
add_executable(07 07.cpp)
|
||||
add_executable(08 08.cpp)
|
||||
add_executable(09 09.cpp)
|
||||
add_executable(10 10.cpp)
|
||||
add_executable(11 11.cpp)
|
||||
Loading…
Reference in new issue