Thu, 21 May 2020 00:10:23 +0800
parent
6920d1c833
commit
341ed2d454
@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmake.configureOnOpen": true
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
#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, a, b, c, d, x, y, x1, y1, x2, y2;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d%d%d%d", &a, &b, &c, &d);
|
||||
scanf("%d%d%d%d%d%d", &x, &y, &x1, &y1, &x2, &y2);
|
||||
if (x1 == x2 && (a || b))
|
||||
{
|
||||
puts("NO");
|
||||
continue;
|
||||
}
|
||||
if (y1 == y2 && (c || d))
|
||||
{
|
||||
puts("NO");
|
||||
continue;
|
||||
}
|
||||
if (x - a + b < x1 || x - a + b > x2)
|
||||
{
|
||||
puts("NO");
|
||||
continue;
|
||||
}
|
||||
if (y - c + d < y1 || y - c + d > y2)
|
||||
{
|
||||
puts("NO");
|
||||
continue;
|
||||
}
|
||||
puts("YES");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
#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 ? gcd(b, a % b) : a;
|
||||
}
|
||||
int a[1005];
|
||||
int g[15];
|
||||
int c[1005];
|
||||
bool flag = false;
|
||||
int T, n, m;
|
||||
|
||||
void dfs(int st)
|
||||
{
|
||||
if (st == n) flag = true;
|
||||
if (flag) return;
|
||||
for (int i = 1; i <= 11; i++)
|
||||
{
|
||||
if (g[i] == 0) g[i] = a[st], m = i;
|
||||
if (gcd(g[i], a[st]) == 1) continue;
|
||||
int p = g[i];
|
||||
g[i] = gcd(g[i], a[st]);
|
||||
c[st] = i;
|
||||
dfs(st + 1);
|
||||
if (flag) return;
|
||||
g[i] = p;
|
||||
}
|
||||
}
|
||||
int primes[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43};
|
||||
int mp[15];
|
||||
int main()
|
||||
{
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++) scanf("%d", a + i);
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 1; j <= 11; j++)
|
||||
if (a[i] % primes[j] == 0)
|
||||
c[i] = j;
|
||||
memset(mp, 0, sizeof(mp));
|
||||
int a = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (mp[c[i]] == 0) mp[c[i]] = ++a;
|
||||
c[i] = mp[c[i]];
|
||||
}
|
||||
printf("%d\n", a);
|
||||
for (int i = 0; i < n; i++) printf("%d%c", c[i], " \n"[i == n - 1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
#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 = 2e5 + 50;
|
||||
char s[N];
|
||||
int cnt[N][27];
|
||||
char tgt[N];
|
||||
int main()
|
||||
{
|
||||
int T, n, k;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d%d%s", &n, &k, s);
|
||||
memset(cnt, 0, sizeof(int) * k * 27);
|
||||
for (int i = 0; i < n; i += k)
|
||||
for (int j = 0; j < k; j++)
|
||||
{
|
||||
cnt[j][s[i + j] - 'a']++;
|
||||
cnt[j][s[i + k - j - 1] - 'a']++;
|
||||
}
|
||||
for (int i = 0; i < k; i++) tgt[i] = 'a' + max_element(cnt[i], cnt[i] + 27) - cnt[i];
|
||||
int ans = 0;
|
||||
for (int i = 0; i < n; i += k)
|
||||
for (int j = 0; j < k; j++)
|
||||
if (s[i + j] != tgt[j]) ans++;
|
||||
printf("%d\n", ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(cf1332)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.3.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,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,60 @@
|
||||
#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;
|
||||
ll fmul(ll a, ll b, ll m)
|
||||
{
|
||||
ll r = 0;
|
||||
for (; b; b >>= 1, a = (a << 1) % m)
|
||||
if (b & 1)
|
||||
r = (r + a) % m;
|
||||
return r;
|
||||
}
|
||||
ll fpow(ll a, ll b, ll m)
|
||||
{
|
||||
ll r = 1;
|
||||
for (; b; b >>= 1, a = fmul(a, a, m))
|
||||
if (b & 1)
|
||||
r = fmul(r, a, m);
|
||||
return r;
|
||||
}
|
||||
bool miller_rabin(ll n, ll a)
|
||||
{
|
||||
ll d = n - 1;
|
||||
if (n == a) return true;
|
||||
if (n & 1 ^ 1) return false;
|
||||
while (d & 1 ^ 1) d >>= 1;
|
||||
ll t = fpow(a, d, n);
|
||||
while (d != n - 1 && t != n - 1 && t != 1)
|
||||
{
|
||||
//t = t * t % n;
|
||||
t = fmul(t, t, n);
|
||||
d <<= 1;
|
||||
}
|
||||
return t == n - 1 || (d & 1) == 1;
|
||||
}
|
||||
bool isPrime(ll x)
|
||||
{
|
||||
auto base = {2, 3, 5, 7, 11, 13, 17, 61, 24251};
|
||||
for (auto a : base)
|
||||
{
|
||||
if (x == a) return true;
|
||||
if (!miller_rabin(x, a)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
inline ll inv(ll x, ll m) { return fpow(x, m - 2, m); }
|
||||
int main()
|
||||
{
|
||||
ll p;
|
||||
cin>>p;
|
||||
cout<<isPrime(p);
|
||||
return 0;
|
||||
}
|
||||
@ -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 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 = 2e5 + 50;
|
||||
struct inp
|
||||
{
|
||||
int st, ed, len;
|
||||
} a[N];
|
||||
char buf[20];
|
||||
vector<int> stw[26], edw[26];
|
||||
int dis[N];
|
||||
bool inq[N];
|
||||
int ideg[N], ideg_copy[N];
|
||||
vector<int>::const_iterator hd[N];
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
scanf("%s", buf);
|
||||
a[i].len = strlen(buf);
|
||||
a[i].st = buf[0] - 'a';
|
||||
a[i].ed = buf[a[i].len - 1] - 'a';
|
||||
stw[a[i].st].push_back(i);
|
||||
edw[a[i].ed].push_back(i);
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
const auto &x = edw[a[i].st];
|
||||
const auto &y = stw[a[i].ed];
|
||||
ideg_copy[i] = lower_bound(x.begin(), x.end(), i) - x.begin();
|
||||
hd[i] = upper_bound(y.begin(), y.end(), i);
|
||||
}
|
||||
int ans = 0;
|
||||
for (int endp = 0; endp < 26; endp++)
|
||||
{
|
||||
queue<int> Q;
|
||||
for (int i = 0; i < n; i++)
|
||||
if ((ideg[i] = ideg_copy[i]) == 0 && a[i].st == endp) Q.push(i);
|
||||
memset(dis, 0, sizeof dis);
|
||||
while (!Q.empty())
|
||||
{
|
||||
int f = Q.front();
|
||||
Q.pop();
|
||||
if (a[f].ed == endp)
|
||||
ans = max(ans, dis[f] + a[f].len);
|
||||
for (auto it = hd[f]; it != stw[a[f].ed].end(); it++)
|
||||
{
|
||||
ideg[*it]--;
|
||||
dis[*it] = max(dis[*it], dis[f] + a[f].len);
|
||||
if (ideg[*it] == 0)
|
||||
Q.push(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0)
|
||||
for (int endp = 0; endp < 26; endp++)
|
||||
{
|
||||
memset(dis, 0, sizeof dis);
|
||||
queue<int> Q;
|
||||
for (auto x : stw[endp]) Q.push(x), inq[x] = true;
|
||||
while (!Q.empty())
|
||||
{
|
||||
int f = Q.front();
|
||||
Q.pop();
|
||||
inq[f] = false;
|
||||
if (a[f].ed == endp) ans = max(ans, dis[f] + a[f].len);
|
||||
for (auto it = upper_bound(stw[a[f].ed].begin(), stw[a[f].ed].end(), f);
|
||||
it != stw[a[f].ed].end(); it++)
|
||||
if (dis[*it] < dis[f] + a[f].len)
|
||||
{
|
||||
dis[*it] = dis[f] + a[f].len;
|
||||
if (!inq[*it]) Q.push(*it), inq[*it] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << ans;
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
#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()
|
||||
{
|
||||
map<ll, ll> m;
|
||||
int n, x;
|
||||
scanf("%d", &n);
|
||||
while (n--)
|
||||
{
|
||||
scanf("%d", &x);
|
||||
m[x]++;
|
||||
}
|
||||
ll ans = 0;
|
||||
for (auto x : m)
|
||||
if (x.first)
|
||||
ans += x.second * m[-x.first];
|
||||
else
|
||||
ans += x.second * (x.second - 1);
|
||||
cout << ans / 2;
|
||||
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,12 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(nowcoder5166)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.3.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)
|
||||
@ -0,0 +1,49 @@
|
||||
#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;
|
||||
char mp[2005][2005];
|
||||
int dp[2005];
|
||||
int main()
|
||||
{
|
||||
int T, n, m;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d%d", &n, &m);
|
||||
for (int i = 0; i < n; i++) scanf("%s", mp[i]);
|
||||
int ans = 0;
|
||||
for (int ch = 'A'; ch <= 'Z'; ch++)
|
||||
{
|
||||
memset(dp, 0, sizeof(dp));
|
||||
int maxsqlen = 0, prev = 0;
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= m; j++)
|
||||
{
|
||||
int temp = dp[j];
|
||||
if (mp[i - 1][j - 1] == ch)
|
||||
{
|
||||
dp[j] = min(min(dp[j - 1], prev), dp[j]) + 1;
|
||||
maxsqlen = max(maxsqlen, dp[j]);
|
||||
}
|
||||
else
|
||||
dp[j] = 0;
|
||||
prev = temp;
|
||||
}
|
||||
ans = max(ans, maxsqlen);
|
||||
}
|
||||
printf("%d\n", ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#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()
|
||||
{
|
||||
long long t, n;
|
||||
cin >> t;
|
||||
while (t--)
|
||||
{
|
||||
cin >> n;
|
||||
cout << (n ? n - 1 : 0) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue