2019 ICPC Asia Yinchuan Regional
Contest Info
[Practice Link](https://www.jisuanke.com/contest/5527?view=challenges)
Solved | A | B | C | D | E | F | G | H | I | J | K | L | M | N |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9/14 | O | O | - | O | - | O | O | O | O | - | O | - | - | O |
- O 在比赛中通过
- Ø 赛后通过
- ! 尝试了但是失败了
- - 没有尝试
Solutions
A. Girls Band Party
题意:
给出一个\(n\),然后给出\(n\)个名字、颜色、分数,然后给出\(5\)个奖励名字和一个奖励颜色,从\(n\)个中选择\(5\)个,选出的\(5\)个名字不重复,如果出现一个奖励名字,则获得\(10\%\)的总评分数,出现一个奖励颜色,则获得\(20\%\)的总评分数,求最大的总评分数
思路:
先将每个名字分为奖励颜色和非奖励颜色两种,分别取\(max\),然后枚举每个奖励名字的不选、选择奖励颜色、选择非奖励颜色三种情况,然后对于剩下需要选择的名字,从非奖励颜色中取前\(10\)个二进制枚举进行选择,剩下的从奖励颜色中选择
代码:
view code
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
const int N = 1e5 + 10;
struct node {
string name;
string col;
int val;
}a[N];
struct qnode {
int id;
int val;
qnode() {}
qnode(int id, int val): id(id), val(val) {}
bool operator < (const qnode &other) const {
return val > other.val;
}
};
int res;
int n, tot;
string name[10], col;
int bor[10][2];
int b[N][2];
map<string, int>mp;
vector<qnode> vec[2];
int vis[N];
int getId(const string &t) {
if (mp.count(t)) return mp[t];
mp[t] = ++tot;
return mp[t];
}
void gao(int pos, int match_name, int match_col, int sum) {
if (pos > 5) {
int limit = min(10, (int)vec[0].size()), sub = 5 - match_name;
for (int S = 0; S < (1 << limit); ++S) {
int tmp = sum;
int match = match_col;
int need = sub;
for (int i = 0; i < limit; ++i) {
if (S & (1 << i)) {
vis[vec[0][i].id] = 1;
tmp += vec[0][i].val;
need--;
}
}
if (need > 0) {
for (auto &it : vec[1]) {
if (!vis[it.id]) {
need--;
tmp += it.val;
match++;
if (need == 0) break;
}
}
}
if (need == 0) {
double other = 0.1 * match_name + 0.2 * match;
tmp = tmp * (1.0 + other);
res = max(res, tmp);
}
for (int i = 0; i < limit; ++i) {
vis[vec[0][i].id] = 0;
}
}
return ;
} else {
gao(pos + 1, match_name, match_col, sum);
if (bor[pos][0])
gao(pos + 1, match_name + 1, match_col, sum + bor[pos][0]);
if (bor[pos][1])
gao(pos + 1, match_name + 1, match_col + 1, sum + bor[pos][1]);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
cin >> T;
while (T--) {
cin >> n;
res = 0;
memset(bor, 0, sizeof bor);
tot = 0;
mp.clear();
vec[0].clear(), vec[1].clear();
memset(b, 0, sizeof b);
for (int i = 1; i <= n; ++i) {
cin >> a[i].name >> a[i].col >> a[i].val;
}
for (int i = 1; i <= 5; ++i) {
cin >> name[i];
}
cin >> col;
for (int i = 1; i <= 5; ++i) getId(name[i]);
for (int i = 1; i <= n; ++i) {
int id = getId(a[i].name);
if (id <= 5) {
if (a[i].col == col) {
bor[id][1] = max(bor[id][1], a[i].val);
} else {
bor[id][0] = max(bor[id][0], a[i].val);
}
} else {
if (a[i].col == col) {
b[id][1] = max(b[id][1], a[i].val);
} else {
b[id][0] = max(b[id][0], a[i].val);
}
}
}
for (int i = 6; i <= tot; ++i) {
for (int j = 0; j < 2; ++j) {
if (b[i][j])
vec[j].push_back(qnode(i, b[i][j]));
}
}
sort(vec[0].begin(), vec[0].end());
sort(vec[1].begin(), vec[1].end());
gao(1, 0, 0, 0);
printf("%d\n", res);
}
return 0;
}
B. So Easy
题意:
给出一个\(n \cdot n\)的矩形,这个矩形\(a_{i, j}\)的初始值为\(0\),它每次能够选择一行或者一列加上\(1\),现在遮住某个位置的数,让你还原这个数。
思路:
考虑倒退操作,不考虑遮住的那个数,然后枚举每行,每列,每次选择行最小,列最小将整行整列减去即可还原出那个数。
代码:
view code
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int n, a[N][N];
int main() {
while (scanf("%d", &n) != EOF) {
int x = -1, y = -1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
scanf("%d", &a[i][j]);
if (a[i][j] == -1) {
x = i, y = j;
a[i][j] = 0;
}
}
}
for (int i = 1; i <= n; ++i) {
int Min = 1e9;
for (int j = 1; j <= n; ++j) {
if (x == i && y == j) continue;
Min = min(Min, a[i][j]);
}
for (int j = 1; j <= n; ++j) {
a[i][j] -= Min;
}
}
for (int j = 1; j <= n; ++j) {
int Min = 1e9;
for (int i = 1; i <= n; ++i) {
if (x == i && y == j) continue;
Min = min(Min, a[i][j]);
}
for (int i = 1; i <= n; ++i) {
a[i][j] -= Min;
}
}
printf("%d\n", -a[x][y]);
}
return 0;
}
D. Easy Problem
题意:
定义一个序列\((a_1, a_2, \cdots, a_n)\)是一个\((n, m, d)-good\)当且仅当\(1 \leq a_i \leq m(1 \leq i \leq n)\)并且\(gcd(a_1, a_2, \cdots, a_n) = d\)
令\(f(a, k) = (a_1a_2\cdots a_n)^k\),现在给出\(n, m, d, k\),让你求所有合法的\((n, m, d)-good\)的序列\(a\)的\(f(a, k)\)
思路:
题目要求的东西等价于:
f(d) = \sum\limits_{a_1 = 1}^m \sum\limits_{a_2 = 1}^m \cdots \sum\limits_{a_n = 1}^m [gcd(a_1, a_2, \cdots, a_n) = d](a_1a_2\cdots a_n)^k
\end{eqnarray*}
\]
那么我们令:
g(d) = \sum\limits_{a_1 = 1}^m \sum\limits_{a_2 = 1}^m \cdots \sum\limits_{a_n = 1}^m [d | gcd(a_1, a_2, \cdots, a_n)](a_1a_2\cdots a_n)^k
\end{eqnarray*}
\]
显然有:
g(d) = (\sum\limits_{d\;|\;i} i^k)^n
\end{eqnarray*}
\]
莫比乌斯反演有:
f(d) &=& \sum\limits_{d\;|\;i} \mu(\frac{i}{d})g(i) \\
&=& \sum\limits_{d\;|\;i} \mu(\frac{i}{d}) (\sum\limits_{i\;|\;j} j^k)^n
\end{eqnarray*}
\]
所以:
\]
代码:
view code
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10, mod = 59964251;
int pri[N], check[N], mu[N], n, m, d, K, phi;
char s[N];
void sieve() {
memset(check, 0, sizeof check);
*pri = 0;
mu[1] = 1;
for (int i = 2; i < N; ++i) {
if (check[i] == 0) {
pri[++*pri] = i;
mu[i] = -1;
}
for (int j = 1; j <= *pri; ++j) {
if (i * pri[j] >= N) break;
check[i * pri[j]] = 1;
if (i % pri[j] == 0) {
mu[i * pri[j]] = 0;
break;
} else {
mu[i * pri[j]] = -mu[i];
}
}
}
}
int eular(int n) {
int ans = n;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) {
ans -= ans / i;
while (n % i == 0)
n /= i;
}
}
if (n > 1) ans -= ans / n;
return ans;
}
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
ll qmod(ll base, ll n) {
ll res = 1;
while (n) {
if (n & 1) res = res * base % mod;
base = base * base % mod;
n >>= 1;
}
return res;
}
int getMod(int mod) {
int res = 0;
for (int i = 1; s[i]; ++i) {
res = (res * 10 + s[i] - '0') % mod;
}
return res;
}
int main() {
phi = eular(mod);
sieve();
// cout << phi << endl;
int _T; scanf("%d", &_T);
while (_T--) {
scanf("%s%d%d%d", s + 1, &m, &d, &K);
int len = strlen(s + 1);
if (len <= 9) {
n = 0;
for (int i = 1; s[i]; ++i) {
n = n * 10 + s[i] - '0';
}
} else {
n = getMod(phi);
if (getMod(643) == 0 || getMod(93257) == 0) {
n += phi;
}
}
ll res = 0;
for (int i = 1; i <= m / d; ++i) {
int base = 0;
for (int j = i * d; j <= m; j += i * d) {
base += qmod(j, K);
base %= mod;
}
res += 1ll * mu[i] * qmod(base, n) % mod;
res = (res + mod) % mod;
}
printf("%lld\n", res);
}
return 0;
}
E. XOR Tree
题意:
定义一个multiset的权值为里面任意两个数的异或和的平方的和。
现在给出一棵有根树(\(1\)为根),每个点有点权,定义\(p(x, k)\)为\(x\)子树中距离\(x\)不超过\(k\)的所有点的点权构成的multiset的权值,现在要对每个\(i \in [1, n]\)求\(p(i, k)\)
F. Function!
G. Pot!!
裸的线段树。
代码:
view code
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, q;
struct SEG {
struct node {
int Max, lazy;
node() { Max = lazy = 0; }
void up(int x) {
Max += x;
lazy += x;
}
node operator + (const node &other) const {
node res = node();
res.Max = max(Max, other.Max);
return res;
}
}t[N << 2];
void build(int id, int l, int r) {
t[id] = node();
if (l == r) return;
int mid = (l + r) >> 1;
build(id << 1, l, mid);
build(id << 1 | 1, mid + 1, r);
}
void down(int id) {
int &lazy = t[id].lazy;
if (lazy) {
t[id << 1].up(lazy);
t[id << 1 | 1].up(lazy);
lazy = 0;
}
}
void update(int id, int l, int r, int ql, int qr, int v) {
if (l >= ql && r <= qr) {
t[id].up(v);
return;
}
int mid = (l + r) >> 1;
down(id);
if (ql <= mid) update(id << 1, l, mid, ql, qr, v);
if (qr > mid) update(id << 1 | 1, mid + 1, r, ql, qr, v);
t[id] = t[id << 1] + t[id << 1 | 1];
}
int query(int id, int l, int r, int ql, int qr) {
if (l >= ql && r <= qr) return t[id].Max;
int mid = (l + r) >> 1;
down(id);
int res = 0;
if (ql <= mid) res = max(res, query(id << 1, l, mid, ql, qr));
if (qr > mid) res = max(res, query(id << 1 | 1, mid + 1, r, ql, qr));
return res;
}
}seg[4];
int main() {
int id[] = {0, 0, 0, 1, 0, 2, 0, 3, 0};
vector <vector<int>> vec;
vec.resize(15);
for (int i = 2; i <= 10; ++i) {
int x = i;
vec[i].clear();
for (int j = 2; j <= x; ++j) {
while (x % j == 0) {
vec[i].push_back(j);
x /= j;
}
}
// cout << i << endl;
// for (auto &it : vec[i])
// cout << it << " ";
// cout << endl;
}
while (scanf("%d%d", &n, &q) != EOF) {
for (int i = 0; i < 4; ++i) seg[i].build(1, 1, n);
char op[20]; int l, r, x;
while (q--) {
scanf("%s%d%d", op, &l, &r);
if (op[1] == 'U') {
scanf("%d", &x);
for (auto &it : vec[x]) {
seg[id[it]].update(1, 1, n, l, r, 1);
}
} else {
int res = 0;
for (int i = 0; i < 4; ++i) {
res = max(res, seg[i].query(1, 1, n, l, r));
}
printf("ANSWER %d\n", res);
}
}
}
return 0;
}
H. Delivery Route
题意:
给出一张图,有\(x\)条无向边,有\(y\)条有向边,保证无向边都是正权值,有向边可能有负权值,并且保证如果一条有向边\(a_i \rightarrow b_i\),那么在该图中,\(b_i\)不可能到达\(a_i\)
现在询问从\(s\)出发到任意一点的最短路。
思路:
我们考虑如果只考虑有向边,那么是一个\(DAG\),那么把无向边连成的每个联通块看成一个新点,并且有有向边将他们连接起来,他们也是一个\(DAG\)。
并且无向图的连通块里面没有负权边,可以跑dijkstra,然后根据拓扑序dp一下即可。
代码:
view code
#include <bits/stdc++.h>
using namespace std;
using pII = pair<int, int>;
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
#define fi first
#define se second
const int N = 5e4 + 10, INF = 0x3f3f3f3f;
int n, mx, my, s, id[N], d[N];
//0 two-way 1 one-way
vector <vector<pII>> G[3];
vector <vector<int>> po;
struct DSU {
int fa[N];
void init() { memset(fa, 0, sizeof fa); }
int find(int x) {
return fa[x] == 0 ? x : fa[x] = find(fa[x]);
}
void merge(int u, int v) {
int fu = find(u), fv = find(v);
if (fu != fv) {
fa[fu] = fv;
}
}
}dsu;
struct node {
int u, w;
node() {}
node(int u, int w) : u(u), w(w) {}
bool operator < (const node &other) const {
return w > other.w;
}
};
int dis[N], used[N];
void Dijkstra(int S) {
priority_queue <node> pq;
pq.push(node(S, dis[S]));
while (!pq.empty()) {
int u = pq.top().u; pq.pop();
for (auto &it : G[0][u]) {
int v = it.fi, w = it.se;
if (dis[v] > dis[u] + w) {
dis[v] = dis[u] + w;
pq.push(node(v, dis[v]));
}
}
}
}
void Topo() {
queue <int> que;
for (int i = 1; i <= *id; ++i) {
if (d[i] == 0) {
que.push(i);
}
}
while (!que.empty()) {
int u = que.front(); que.pop();
sort(po[u].begin(), po[u].end(), [&](int a, int b) { return dis[a] < dis[b]; });
for (auto &it : po[u]) {
Dijkstra(it);
for (auto &it2 : G[1][it]) {
int v = it2.fi, w = it2.se;
if (dis[it] < INF) {
dis[v] = min(dis[v], dis[it] + w);
}
}
}
for (auto &it : G[2][u]) {
int v = it.fi;
if (--d[v] == 0) {
que.push(v);
}
}
}
}
int main() {
while (scanf("%d%d%d%d", &n, &mx, &my, &s) != EOF) {
for (int i = 1; i <= n; ++i) {
dis[i] = INF;
}
dis[s] = 0;
*id = 0;
G[0].clear(); G[1].clear();
G[0].resize(n + 1); G[1].resize(n + 1);
for (int i = 1, u, v, w; i <= mx; ++i) {
scanf("%d%d%d", &u, &v, &w);
G[0][u].push_back(pII(v, w));
G[0][v].push_back(pII(u, w));
}
for (int i = 1, u, v, w; i <= my; ++i) {
scanf("%d%d%d", &u, &v, &w);
G[1][u].push_back(pII(v, w));
}
dsu.init();
for (int u = 1; u <= n; ++u) {
for (auto &it : G[0][u]) {
int v = it.fi;
dsu.merge(u, v);
}
}
for (int u = 1; u <= n; ++u) {
if (dsu.fa[u] == 0)
id[u] = ++*id;
}
for (int u = 1; u <= n; ++u) {
if (dsu.fa[u]) {
id[u] = id[dsu.find(u)];
}
}
// for (int i = 1; i <= n; ++i)
// dbg(i, id[i]);
po.clear(); po.resize(*id + 10);
G[2].clear(); G[2].resize(*id + 10);
memset(d, 0, sizeof d);
for (int u = 1; u <= n; ++u) {
po[id[u]].push_back(u);
for (auto &it : G[1][u]) {
int v = it.fi;
if (id[u] != id[v]) {
G[2][id[u]].push_back(pII(id[v], v));
++d[id[v]];
}
}
}
Topo();
for (int i = 1; i <= n; ++i) {
if (dis[i] >= INF) puts("NO PATH");
else printf("%d\n", dis[i]);
}
}
return 0;
}
I. Base62
题意:
进制转换
代码:
view code
def main():
l = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
x, y, z = input().split()
x = int(x)
y = int(y)
num = 0
for c in z:
if ord('0') <= ord(c) <= ord('9'):
num = num * x + ord(c) - ord('0')
elif ord('A') <= ord(c) <= ord('Z'):
num = num * x + ord(c) - ord('A') + 10
else:
num = num * x + ord(c) - ord('a') + 36
if num == 0:
print("0")
return
res = ""
while num > 0:
tmp = num % y
res = res + l[tmp]
num = num // y
# print(res)
res = res[::-1]
print(res)
main()
K. Largest Common Submatrix
题意:
给出两个\(n \cdot m\)的矩形,并且里面的数是\([1, nm]\)的排列。
求两个矩形的最大公共子矩形,这里的大定义为面积。
思路:
考虑里面的数是一个排列,可以\(O(n^2)\)处理出每个数向上拓展多少,向左右拓展多少,然后考虑每一行,肯定是某段连续的长度然后乘上这段最小的向上拓展的数量。
向上拓展的这部分当成一个维,位置当成一维,丢进笛卡尔树里面跑一跑能跑出每个最小值管辖的范围,然后和左右扩展的范围求交,就是每个向上拓展数量在横向最远能扩展的范围。
代码:
view code
#include <bits/stdc++.h>
using namespace std;
using pII = pair<int, int>;
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
#define fi first
#define se second
const int N = 1e3 + 10, INF = 0x3f3f3f3f;
int n, m, a[N][N], b[N][N], l[N][N], r[N][N], num[N][N];
pII c[N], id[N * N];
struct CT {
struct node {
int id, val, fa;
int son[2];
node() {}
node (int id, int val, int fa) : id(id), val(val), fa(fa) {
son[0] = son[1] = 0;
}
bool operator < (const node &other) const {
return val < other.val;
}
}t[N];
int root;
void init() {
t[0] = node(0, -INF, 0);
}
void build(int n, int *a) {
for (int i = 1; i <= n; ++i) {
t[i] = node(i, a[i], 0);
}
for (int i = 1; i <= n; ++i) {
int k = i - 1;
while (t[i] < t[k]) {
k = t[k].fa;
}
t[i].son[0] = t[k].son[1];
t[k].son[1] = i;
t[i].fa = k;
t[t[i].son[0]].fa = i;
}
root = t[0].son[1];
}
int dfs(int u) {
if (!u) return 0;
c[u].fi = dfs(t[u].son[0]);
c[u].se = dfs(t[u].son[1]);
return c[u].fi + c[u].se + 1;
}
}ct;
int main() {
while (scanf("%d%d", &n, &m) != EOF) {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
scanf("%d", &a[i][j]);
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
scanf("%d", &b[i][j]);
id[b[i][j]] = pII(i, j);
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (j == 1) {
l[i][j] = j;
} else {
int pre = a[i][j - 1], now = a[i][j];
if (id[pre].fi == id[now].fi && id[pre].se == id[now].se - 1) {
l[i][j] = l[i][j - 1];
} else {
l[i][j] = j;
}
}
}
for (int j = m; j >= 1; --j) {
if (j == m) {
r[i][j] = j;
} else {
int nx = a[i][j + 1], now = a[i][j];
if (id[nx].fi == id[now].fi && id[nx].se == id[now].se + 1) {
r[i][j] = r[i][j + 1];
} else {
r[i][j] = j;
}
}
}
}
for (int j = 1; j <= m; ++j) {
for (int i = 1; i <= n; ++i) {
if (i == 1) {
num[i][j] = 1;
} else {
int pre = a[i - 1][j], now = a[i][j];
if (id[pre].fi == id[now].fi - 1 && id[pre].se == id[now].se) {
num[i][j] = num[i - 1][j] + 1;
} else {
num[i][j] = 1;
}
}
}
}
int res = 0;
for (int i = 1; i <= n; ++i) {
// for (int j = 1; j <= m; ++j) {
// dbg(i, j, l[i][j], r[i][j], num[i][j]);
// }
ct.init();
ct.build(n, num[i]);
ct.dfs(ct.root);
for (int j = 1; j <= m; ++j) {
int tl = max(l[i][j], j - c[j].fi);
int tr = min(r[i][j], j + c[j].se);
res = max(res, (tr - tl + 1) * num[i][j]);
}
}
printf("%d\n", res);
}
return 0;
}
N. Fibonacci Sequence
纯输出题
2019 ICPC Asia Yinchuan Regional的更多相关文章
- 2019 ICPC Asia Nanjing Regional
2019 ICPC Asia Nanjing Regional A - Hard Problem 计蒜客 - 42395 若 n = 10,可以先取:6,7,8,9,10.然后随便从1,2,3,4,5 ...
- 2019 ICPC Asia Nanjing Regional K. Triangle
题目:在直角坐标系中给定 p1,p2,p3构成三角形,给定p4可能在三角形边上也可能不在, 问能不能在三角形上找出p5,使得线段p4p5,平分三角形(p4必须在三角形上).不能则输出-1. 思路:四个 ...
- 2019 ICPC Asia Xuzhou Regional
目录 Contest Info Solutions A. Cat B. Cats line up C. <3 numbers E. Multiply F. The Answer to the U ...
- 2019 ICPC Asia Nanchang Regional C And and Pair 找规律/位运算/dp
题意: 给定一个二进制表示的n,让你找满足如下要求的数对(i,j)的个数 $0 \leqslant j \leqslant i \leqslant n$ $ i & n = i $ $ i & ...
- 2019 ICPC Asia Nanchang Regional E Eating Plan 离散化+前缀和
题意: 给你n个盘子,这n个盘子里面分别装着1!到n!重量的食物,对于每一个询问k,找出一个最短的区间,使得区间和 mod 998857459 大于或等于k 盘子数量 n<=1e5 询问次数 m ...
- The 2019 ICPC Asia Shanghai Regional Contest H Tree Partition k、Color Graph
H题意: 给你一个n个节点n-1条无向边构成的树,每一个节点有一个权值wi,你需要把这棵树划分成k个子树,每一个子树的权值是这棵子树上所有节点权值之和. 你要输出这k棵子树的权值中那个最大的.你需要让 ...
- 2019 ICPC Asia Taipei-Hsinchu Regional Problem J Automatic Control Machine (DFS,bitset)
题意:给你\(m\)个长度为\(n\)的二进制数,求最少选多少个使它们\(|\)运算后所有位置均为\(1\),如果不满足条件,则输出\(-1\). 题解:这题\(n\)的范围很大,所以我们先用\(st ...
- 2019 ICPC Asia Taipei-Hsinchu Regional Problem K Length of Bundle Rope (贪心,优先队列)
题意:有\(n\)堆物品,每次可以将两堆捆成一堆,新堆长度等于两个之和,每次消耗两个堆长度之和的长度,求最小消耗使所有物品捆成一堆. 题解:贪心的话,每次选两个长度最小的来捆,这样的消耗一定是最小的, ...
- 2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)
题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine ...
随机推荐
- PowerBuilder学习笔记之2PowerScript语言(二)
z教材地址:https://wenku.baidu.com/view/1e82d26925c52cc58ad6be05.html?sxts=1565679996440 2.4数组 声明数组:Integ ...
- Nginx学习笔记(五):高级数据结构
目录 动态数组 单向链表 双端队列 红黑树 缓冲区 数据块链 键值对 动态数组 ngx_array_t 表示一块连续的内存,其中存放着数组元素,概念上和原始数组很接近 // 定义在 core/ng ...
- Sonya and Matrix Beauty CodeForces - 1080E (manacher)
大意: 给定$nm$字符串矩阵. 若一个子矩形每一行重排后可以满足每行每列都是回文, 那么它为好矩形. 求所有好矩形个数. 一个矩形合法等价于每一行出现次数为奇数的最多只有一个字符, 并且对称的两行对 ...
- windows下mysql表名区分大小写
windows下mysql默认是不区分大小写的,但是linux会区分大小写 如何让windows下mysql区分大小写呢? 修改 my.ini 里面的mysqld部分 #区分大小写 lower_cas ...
- Python之(matplotlib、numpy、pandas)数据分析
一.Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形. 它主要用来回事图形,用来展现一些数据,更加直观的展示,让你第一眼就只要数 ...
- jquery input file 多图上传,单张删除,查看
<div class="form-group"> <label for="imgs" class="col-md-3 col-sm- ...
- Vue.use()源码分析且执行后干什么了
直接开始分析源码 // Vue源码文件路径:src/core/global-api/use.js import { toArray } from '../util/index' //initUse函数 ...
- cd .ssh返回-bash: cd: .ssh:No such file or directory怎么办
继续上一篇博文 今天再次陷入同样的问题 避免这个问题的另一个套路是用节点和其他节点直接ssh 远程连接,需要输入密码, 但是输入再次退出之后就OK了 cd 可以到.ssh了 然后就可以开心的免密了
- nginx 之高级模块
secure_link_module 模块 作用: 制定并允许检查请求的链接的真实性以及保护资源免遭未经授权的访问 限制链接生效周期 配置语法 Syntax:secure_link expressio ...
- 微信H5支付(基于Java实现微信H5支付)
微信的H5支付区别与APP支付,主要在于预下单(返回的参数不一样),其它大体相同(基本没什么区别,区别在于有些人加密喜欢用MD5有些人喜欢用官方提供的加密方式加密,我用的是官方的),贴一下H5支付预下 ...