Mon, 12 Aug 2019 18:52:21 +0800

master
大蒟蒻 6 years ago
parent e128a72a05
commit 70e024b43b

@ -0,0 +1,50 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 1e5 + 50;
char s[N];
bool r[10];
int main()
{
int n;
scanf("%d%s", &n, s);
for (int i = 0; i < n; i++)
{
switch (s[i])
{
case 'L':
for (int i = 0; i <= 9; i++)
if (!r[i])
{
r[i] = true;
break;
}
break;
case 'R':
for (int i = 9; i >= 0; i--)
if (!r[i])
{
r[i] = true;
break;
}
break;
default:
r[s[i] - '0'] = false;
break;
}
}
for (int i = 0; i < 10; i++) putchar('0' + r[i]);
return 0;
}

@ -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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 1e6 + 60;
int h[N];
int main()
{
int T, n, m, k;
scanf("%d", &T);
while (T--)
{
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < n; i++) scanf("%d", h + i);
bool flag = true;
for (int i = 0; i < n - 1; i++)
{
int target = max(0, h[i + 1] - k);
if (h[i] + m < target)
{
flag = false;
break;
}
m += h[i] - target;
}
puts(flag ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,30 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
ll n, m, q, sx, sy, ex, ey;
scanf("%lld%lld%lld", &n, &m, &q);
ll g = gcd(n, m);
while (q--)
{
scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey);
int blkid1 = (sy - 1) / ((sx == 1 ? n : m) / g);
int blkid2 = (ey - 1) / ((ex == 1 ? n : m) / g);
puts(blkid1 == blkid2 ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,12 @@
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(A A.cpp)
add_executable(B B.cpp)
add_executable(C C.cpp)
add_executable(D D.cpp)
add_executable(E E.cpp)
add_executable(F F.cpp)

@ -0,0 +1,50 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 2005;
char buf[N][N];
int a[N][N];
int main()
{
int n, k;
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++) scanf("%s", buf + i);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + (buf[i - 1][j - 1] == 'B');
int ans = 0;
for (int i = 1; i <= n - k + 1; i++)
for (int j = 1; j <= n - k + 1; j++)
{
int cur = 0;
for (int l = 1; l <= n; l++)
{
int cnt = a[l][n] - a[l - 1][n];
if (i <= l && l <= i + k - 1)
cnt -= a[l][j + k - 1] - a[l][j - 1] - a[l - 1][j + k - 1] + a[l - 1][j - 1];
if (cnt == 0) cur++;
}
for (int l = 1; l <= n; l++)
{
int cnt = a[n][l] - a[n][l - 1];
if (j <= l && l <= j + k - 1)
cnt -= a[i + k - 1][l] - a[i - 1][l] - a[i + k - 1][l - 1] + a[i - 1][l - 1];
if (cnt == 0) cur++;
}
ans = max(ans, cur);
}
printf("%d", ans);
return 0;
}

@ -0,0 +1,30 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 1e6 + 60;
char ans[N], buf[N], an;
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
scanf("%s", buf);
int len = strlen(buf);
}
puts(ans);
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
template <typename T>
inline void read(T &x)
{
int ch = x = 0;
while (!isdigit(ch)) ch = getchar();
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
}
int main()
{
ll t, n, m, k;
read(t);
while (t--)
{
read(n), read(m), read(k);
if (k == n)
printf("%lld\n", n * (m + 1));
else
{
ll base = m / n;
ll cnt = (n - m % n) % n;
printf("%lld\n", base * k + max(0ll, k - cnt) + k);
}
}
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
int main()
{
return 0;
}

@ -0,0 +1,93 @@
#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 OPX(tr, op, t, x) tr operator op(CRP(t, x)) const
#define OPL(t, x) OPX(bool, <, t, x)
#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)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
const ll mod = 1e9 + 7;
inline ll fpow(ll a, ll b)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % mod)
if (b & 1)
r = r * a % mod;
return r;
}
inline ll inv(ll x) { return fpow(x, mod - 2); }
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + S;
return S == T ? EOF : *S++;
}
template <typename T>
inline typename enable_if<is_integral<T>::value>::type read(T &x)
{
int ch = x = 0;
while (!isdigit(ch)) ch = getchar(0);
for (; isdigit(ch); ch = getchar(0)) x = x * 10 + ch - '0';
}
const int N = 5e5 + 50;
ll r[N], s[N], x[N], a[N];
struct frac
{
ll h, l;
OPX(frac, +, frac, rhs)
{
return frac{h * rhs.l + l * rhs.h, l * rhs.l}.reduce();
}
OPX(frac, -, frac, rhs)
{
return frac{h * rhs.l + l * -rhs.h, l * rhs.l}.reduce();
}
OPX(frac, *, frac, rhs)
{
return frac{h * rhs.h, l * rhs.l}.reduce();
}
OPX(frac, /, frac, rhs)
{
return frac{h * rhs.l, l * rhs.h}.reduce();
}
frac &reduce()
{
if (l == 0) l = 1;
ll g = gcd(h, l);
if (g > 1) h /= g, l /= g;
return *this;
}
void print()
{
reduce();
printf("%lld\n", ll(h * inv(l) % mod));
}
};
frac psum[N];
int main()
{
int T, n, q;
read(T);
while (T--)
{
read(n), read(q);
for (int i = 1; i <= n; i++) read(r[i]), read(s[i]), read(x[i]), read(a[i]);
psum[0] = psum[1] = {0, 1};
for (int i = 1; i <= n; i++)
psum[i + 1] = psum[i] +
frac{a[i], 1} * frac{s[i], r[i]} +
(psum[i] - psum[x[i]]) * frac{s[i] - r[i], r[i]};
for (int i = 1, l, r; i <= q; i++)
read(l), read(r), (psum[r] - psum[l]).print();
}
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…
Cancel
Save