Fri, 06 Dec 2019 13:46:06 +0800
parent
29a147d356
commit
6f3f84649d
Binary file not shown.
@ -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(op, t, x) operator op(CRP(t, x))
|
||||
#define OPL(t, x) bool OPX(<, 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 int64_t ll, i64;
|
||||
typedef uint64_t ull, u64;
|
||||
template <typename... Types>
|
||||
using comtype = typename common_type<Types...>::type;
|
||||
template <typename T>
|
||||
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
|
||||
template <typename T>
|
||||
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
|
||||
inline char getchar(int)
|
||||
{
|
||||
static char buf[64 << 20], *S = buf, *T = buf;
|
||||
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
|
||||
return S == T ? EOF : *S++;
|
||||
}
|
||||
template <typename T, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x)
|
||||
{
|
||||
int ch = x = 0, f = 1;
|
||||
while (!isdigit(ch = getchar()))
|
||||
if (ch == EOF)
|
||||
return false;
|
||||
else if (ch == '-')
|
||||
f = 0;
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
return x = f ? x : -x, true;
|
||||
}
|
||||
template <typename T, typename... Args, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
|
||||
inline ll gcd(ll a, ll b)
|
||||
{
|
||||
for (; b; swap(a, b)) a %= b;
|
||||
return a;
|
||||
}
|
||||
inline ll fpow(ll a, ll b, ll m)
|
||||
{
|
||||
ll r = 1;
|
||||
for (; b; b >>= 1, a = a * a % m)
|
||||
if (b & 1) r = r * a % m;
|
||||
return r;
|
||||
}
|
||||
constexpr double eps = 1e-8;
|
||||
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
|
||||
const int N = 2050;
|
||||
char s[N], t[N];
|
||||
vector<pair<int, int>> v;
|
||||
int main()
|
||||
{
|
||||
int T, n, k;
|
||||
read(T);
|
||||
while (T--)
|
||||
{
|
||||
v.clear();
|
||||
read(n, k);
|
||||
scanf("%s", s);
|
||||
int sp = 0;
|
||||
for (int i = 0; i < k - 1; i++) t[sp++] = '(', t[sp++] = ')';
|
||||
for (int i = 0; i < (n >> 1) - k + 1; i++) t[sp++] = '(';
|
||||
for (int i = 0; i < (n >> 1) - k + 1; i++) t[sp++] = ')';
|
||||
for (int i = 0; i < n; i++)
|
||||
if (s[i] != t[i])
|
||||
{
|
||||
auto po = strchr(s + i, t[i]);
|
||||
reverse(s + i, po + 1);
|
||||
v.push_back({i + 1, po - s + 1});
|
||||
}
|
||||
printf("%d\n", (int)v.size());
|
||||
for (const auto &p : v) printf("%d %d\n", p.first, p.second);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,92 @@
|
||||
#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(op, t, x) operator op(CRP(t, x))
|
||||
#define OPL(t, x) bool OPX(<, 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 int64_t ll, i64;
|
||||
typedef uint64_t ull, u64;
|
||||
template <typename... Types>
|
||||
using comtype = typename common_type<Types...>::type;
|
||||
template <typename T>
|
||||
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
|
||||
template <typename T>
|
||||
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
|
||||
inline char getchar(int)
|
||||
{
|
||||
static char buf[64 << 20], *S = buf, *T = buf;
|
||||
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
|
||||
return S == T ? EOF : *S++;
|
||||
}
|
||||
template <typename T, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x)
|
||||
{
|
||||
int ch = x = 0, f = 1;
|
||||
while (!isdigit(ch = getchar()))
|
||||
if (ch == EOF)
|
||||
return false;
|
||||
else if (ch == '-')
|
||||
f = 0;
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
return x = f ? x : -x, true;
|
||||
}
|
||||
template <typename T, typename... Args, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
|
||||
inline ll gcd(ll a, ll b)
|
||||
{
|
||||
for (; b; swap(a, b)) a %= b;
|
||||
return a;
|
||||
}
|
||||
inline ll fpow(ll a, ll b, ll m)
|
||||
{
|
||||
ll r = 1;
|
||||
for (; b; b >>= 1, a = a * a % m)
|
||||
if (b & 1) r = r * a % m;
|
||||
return r;
|
||||
}
|
||||
constexpr double eps = 1e-8;
|
||||
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
|
||||
int a[105], b[105];
|
||||
int main()
|
||||
{
|
||||
int n, m, k, p;
|
||||
read(n);
|
||||
for (int i = 0; i < n; i++) read(a[i]);
|
||||
memcpy(b, a, sizeof(int) * n);
|
||||
sort(b, b + n, greater<int>());
|
||||
read(m);
|
||||
while (m--)
|
||||
{
|
||||
read(k, p);
|
||||
int x = b[k - 1];
|
||||
int gx = lower_bound(b, b + n, x, greater<int>()) - b;
|
||||
for (int i = 0, j = 0, l = 0; i < n; i++)
|
||||
{
|
||||
if (a[i] > x) j++;
|
||||
if (a[i] == x && l < k - gx) j++, l++;
|
||||
if (j == p)
|
||||
{
|
||||
printf("%d\n", a[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,79 @@
|
||||
#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(op, t, x) operator op(CRP(t, x))
|
||||
#define OPL(t, x) bool OPX(<, 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 int64_t ll, i64;
|
||||
typedef uint64_t ull, u64;
|
||||
template <typename... Types>
|
||||
using comtype = typename common_type<Types...>::type;
|
||||
template <typename T>
|
||||
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
|
||||
template <typename T>
|
||||
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
|
||||
inline char getchar(int)
|
||||
{
|
||||
static char buf[64 << 20], *S = buf, *T = buf;
|
||||
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
|
||||
return S == T ? EOF : *S++;
|
||||
}
|
||||
template <typename T, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x)
|
||||
{
|
||||
int ch = x = 0, f = 1;
|
||||
while (!isdigit(ch = getchar()))
|
||||
if (ch == EOF)
|
||||
return false;
|
||||
else if (ch == '-')
|
||||
f = 0;
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
return x = f ? x : -x, true;
|
||||
}
|
||||
template <typename T, typename... Args, typename = enable_if_integral<T>>
|
||||
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
|
||||
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
|
||||
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
|
||||
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
|
||||
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
|
||||
inline ll gcd(ll a, ll b)
|
||||
{
|
||||
for (; b; swap(a, b)) a %= b;
|
||||
return a;
|
||||
}
|
||||
inline ll fpow(ll a, ll b, ll m)
|
||||
{
|
||||
ll r = 1;
|
||||
for (; b; b >>= 1, a = a * a % m)
|
||||
if (b & 1) r = r * a % m;
|
||||
return r;
|
||||
}
|
||||
constexpr double eps = 1e-8;
|
||||
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
|
||||
int main()
|
||||
{
|
||||
ll T, r, b, k;
|
||||
read(T);
|
||||
while (T--)
|
||||
{
|
||||
read(r, b, k);
|
||||
ll g = gcd(r, b);
|
||||
r /= g, b /= g;
|
||||
if (r > b) swap(r, b);
|
||||
puts((k - 1) * r + 1 < b ? "REBEL" : "OBEY");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#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()
|
||||
{
|
||||
int T, n;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d", &n);
|
||||
while (n % 2 == 0) n /= 2;
|
||||
while (n % 5 == 0) n /= 5;
|
||||
puts(n > 1 ? "Yes" : "No");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
#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); }
|
||||
constexpr ll mod = 998244353;
|
||||
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;
|
||||
}
|
||||
ll fpow(ll a, ll b, ll m = mod)
|
||||
{
|
||||
ll r = 1;
|
||||
for (; b; b >>= 1, a = a * a % m)
|
||||
if (b & 1)
|
||||
r = r * a % m;
|
||||
return r;
|
||||
}
|
||||
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>
|
||||
using isInt = typename enable_if<is_integral<T>::value>::type;
|
||||
template <typename T, typename = isInt<T>>
|
||||
inline void read(T &x)
|
||||
{
|
||||
int ch = x = 0, f = 1;
|
||||
while (!isdigit(ch = getchar()))
|
||||
if (ch == '-') f = -1;
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
x *= f;
|
||||
}
|
||||
template <typename T, typename... Args, typename = isInt<T>>
|
||||
inline void read(T &x, Args &... args) { read(x), read(args...); }
|
||||
int main()
|
||||
{
|
||||
int a, b, c, d;
|
||||
double e;
|
||||
read(a, b, c, d);
|
||||
cout << a << endl;
|
||||
cout << b << endl;
|
||||
cout << c << endl;
|
||||
cout << d << endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue