pat1121-1131
1121
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e6+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int pai[N];
int a[N];
int has[N];
int ord[N];
int main() {
int n;
while(~scanf("%d", &n)) {
memset(pai, -1, sizeof(pai));
for(int i = 0; i < n; ++i) {
int a, b; scanf("%d%d", &a, &b);
pai[a] = b; pai[b] = a;
}
int m; scanf("%d", &m);
for(int i = 0; i < m; ++i) {
scanf("%d", &a[i]);
has[a[i]] ++; if(pai[a[i]] != -1) has[pai[a[i]]] ++;
}
int tot = 0;
for(int i = 0; i < m; ++i) {
if(has[a[i]] == 1) {
ord[tot ++] = a[i];
}
}
sort(ord, ord + tot);
printf("%d\n", tot);
for(int i = 0; i < tot; ++i) {
if(i) printf(" ");
printf("%05d", ord[i]);
}
if(tot) printf("\n");
}
return 0;
}
1122 我把爆搜都写完了,才发现这题的圈顺序是给定的,我爆搜就不删了
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 205;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
struct Node{
int to, nx;
}E[N*N*2];
int mp[N][N];
int head[N], tot;
void add(int fr, int to) {
E[tot].to = to; E[tot].nx = head[fr]; head[fr] = tot ++;
}
set<int> st;
int suc;
void dfs(int l, int r) {
printf("%d %d\n", l, r);
if(suc) return;
if(st.size() == 0) {
if(mp[l][r]) suc = 1;
return;
}
if(st.size() == 1) {
int tt = *st.begin();
if(mp[l][tt] && mp[r][tt]) {
suc = 1;
}
return;
}
vector<int> ch1; vector<int> ch2;
for(int i = head[l]; ~i; i = E[i].nx) {
if(st.find(E[i].to) != st.end()) {
ch1.push_back(E[i].to);
}
}
if(l == r) {
for(int i = 0; i < ch1.size() && !suc; ++i) {
for(int j = i+1; j < ch1.size() && !suc; ++j) {
st.erase(ch1[i]); st.erase(ch1[j]);
dfs(ch1[i], ch1[j]);
st.insert(ch1[i]); st.insert(ch1[j]);
}
}
return;
}
for(int i = head[r]; ~i; i = E[i].nx) {
if(st.find(E[i].to) != st.end()) {
ch2.push_back(E[i].to);
}
}
for(int i = 0; i < ch1.size() && !suc; ++i) {
for(int j = 0; j < ch2.size() && !suc; ++j) {
if(ch1[i] != ch2[j]) {
st.erase(ch1[i]); st.erase(ch2[j]);
dfs(ch1[i], ch2[j]);
st.insert(ch1[i]); st.insert(ch2[j]);
}
}
}
}
int main() {
int n,m;
while(~scanf("%d %d", &n, &m)) {
memset(head, -1, sizeof(head));
tot = 0;
for(int i = 0; i < m; ++i) {
int a, b; scanf("%d %d", &a, &b);
add(a, b); add(b, a);
mp[a][b] = mp[b][a] = 1;
}
int k; scanf("%d", &k);
while(k --) {
int a; scanf("%d", &a);
int fl = 1;
st.clear();
int pre = -1;
int St = -1;
for(int i = 0; i < a; ++i) {
int b; scanf("%d", &b);
if(St == -1) St = b;
if(st.find(b) != st.end() && i != a-1) fl = 0;
if(i == a-1 && St != b) fl = 0;
if(~pre && !mp[b][pre]) fl = 0;
pre = b;
st.insert(b);
}
// int tt = *st.begin(); st.erase(tt);
// suc = 0;
// dfs(tt, tt);
if(fl && a > 4) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
1123 和之前一道avl类似
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 25;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int root;
int num[N];
int L[N], R[N], fa[N];
int n;
void insert(int x, int tag) {
// printf("tag: %d\n", x);
if(!root) {
root = tag; fa[tag] = tag; return;
}
if(num[x] > num[tag]) {
if(!L[x]) L[x] = tag, fa[tag] = x;
else insert(L[x], tag);
}else {
if(!R[x]) R[x] = tag, fa[tag] = x;
else insert(R[x], tag);
}
}
struct Node{
int po, val;
Node(int a=0, int b=0):po(a), val(b){}
}E[10];
int cmp(Node a,Node b) {
return a.val < b.val;
}
void LL(int x) {
// printf("LL\n");
int fart = fa[fa[x]];
int t1 = x; int t2 = R[x]; int t3 = fa[x];
fa[t1] = 0; fa[t2] = 0; fa[t3] = 0;
R[t1] = t3; fa[t3] = t1;
L[t3] = t2; fa[t2] = t3;
if(t3 == root) {
root = t1; fa[t1] = t1;
}else if(L[fart] == t3) {
L[fart] = t1; fa[t1] = fart;
}else R[fart] = t1, fa[t1] = fart;
}
void RR(int x) {
// printf("RR\n");
int fart = fa[fa[x]];
int t1 = x; int t2 = L[x]; int t3 = fa[x];
fa[t1] = 0; fa[t2] = 0; fa[t3] = 0;
L[t1] = t3; fa[t3] = t1;
R[t3] = t2; fa[t2] = t3;
if(t3 == root) {
root = t1; fa[t1] = t1;
}else if(L[fart] == t3) {
L[fart] = t1; fa[t1] = fart;
}else R[fart] = t1, fa[t1] = fart;
}
void LR(int x, int tag) {
// printf("LR\n");
int fart = fa[fa[x]];
int t1 = x; int t2 = R[x]; int t3 = fa[x];
int a1 = L[t2]; int a2 = R[t2];
fa[t1] = 0; fa[t2] = 0; fa[t3] = 0;
R[t1] = 0; L[t3] = 0;
L[t2] = t1; fa[t1] = t2;
R[t2] = t3; fa[t3] = t2;
if(t3 == root) {
root = t2; fa[t2] = t2;
}else if(L[fart] == t3) {
L[fart] = t2; fa[t2] = fart;
}else {
R[fart] = t2; fa[t2] = fart;
}
if(a1) insert(root, a1);
if(a2) insert(root, a2);
}
void RL(int x, int tag) {
// printf("RL\n");
int fart = fa[fa[x]];
int t1 = x; int t2 = L[x]; int t3 = fa[x];
int a1 = L[t2]; int a2 = R[t2];
L[t1] = 0; R[t3] = 0;
fa[t1] = 0; fa[t2] = 0; fa[t3] = 0;
L[t2] = t3; fa[t3] = t2;
R[t2] = t1; fa[t1] = t2;
// printf("hh %d %d %d\n", num[t1], num[t2], num[t3]);
if(t3 == root) {
root = t2; fa[t2] = t2;
}else if(L[fart] == t3) {
L[fart] = t2; fa[t2] = fart;
}else {
R[fart] = t2; fa[t2] = fart;
}
// printf("hh %d %d", fart, R[fart]);
if(a1) insert(root, a1);
if(a2) insert(root, a2);
}
void fix(int x) {
int rt = fa[fa[x]]; int fart = fa[rt];
if( (L[rt]==0) + (R[rt]==0) == 1) {
int tot = 0;
for(int i = 0, tt = x; i < 3; ++i) {
E[tot++] = Node(tt, num[tt]);
tt = fa[tt];
}
sort(E, E+tot, cmp);
L[E[1].po] = E[0].po; fa[E[0].po] = E[1].po;
R[E[1].po] = E[2].po; fa[E[2].po] = E[1].po;
L[E[0].po] = 0; R[E[0].po] = 0;
L[E[2].po] = 0; R[E[2].po] = 0;
if(root == rt) {
root = E[1].po; fa[root] = root;
}else if(L[fart] == rt) {
L[fart] = E[1].po; fa[E[1].po] = fart;
}else {
R[fart] = E[1].po; fa[E[1].po] = fart;
}
}else {
// printf("%d %d %d\n", x, rt, fa[rt]);
if (L[fa[rt]] == rt && L[rt] == fa[x] ) LL(rt);
else if(R[fa[rt]] == rt && R[rt] == fa[x] ) RR(rt);
else if(L[fa[rt]] == rt && R[rt] == fa[x] ) LR(rt, x);
else if(R[fa[rt]] == rt && L[rt] == fa[x] ) RL(rt, x);
}
}
void test(int x, int pre) {
printf("%d from %d\n", x, pre);
if(L[x]) test(L[x], x);
if(R[x]) test(R[x], x);
}
int height[N]; int tag;
void dfs(int x) {
int t1 = 0, t2 = 0;
if(L[x]) dfs(L[x]), t1 = height[L[x]];
if(R[x]) dfs(R[x]), t2 = height[R[x]];
height[x] = max(t1, t2)+1;
if( abs(t1- t2) > 1 && !tag) tag = x;
}
void solve(int x) {
// printf("do %d\n", x);
memset(height, 0, sizeof(height));
tag = 0;
dfs(root);
if(tag) {
int t1 = tag;
if(height[L[t1]] > height[R[t1]]) t1 = L[t1];
else t1 = R[t1];
if(height[L[t1]] > height[R[t1]]) t1 = L[t1];
else t1 = R[t1];
if(height[L[t1]] > height[R[t1]]) t1 = L[t1];
else if(height[L[t1]] < height[R[t1]]) t1 = R[t1];
// printf("%d %d\n", tag, t1);
fix(t1);
}
// test(root, root);
// printf("\n");
}
void bfs(int x) {
int all = 0;
queue<int> Q;
Q.push(x);
while(Q.front() != 0) {
int po = Q.front(); Q.pop();
all ++;
Q.push(L[po]); Q.push(R[po]);
}
while(!Q.empty()) Q.pop();
Q.push(x);
int nn = 0;
while(!Q.empty()) {
int po = Q.front(); Q.pop();
if(!nn) nn = 1; else printf(" ");
printf("%d", num[po]);
if(L[po]) Q.push(L[po]);
if(R[po]) Q.push(R[po]);
}
printf("\n");
if(all == n) printf("YES\n");
else printf("NO\n");
}
int main() {
while(~scanf("%d", &n)) {
root = 0;
memset(fa, 0, sizeof(fa));
memset(L, 0, sizeof(L));
memset(R, 0, sizeof(R));
for(int i = 1; i <= n; ++i) {
scanf("%d", &num[i]);
insert(root, i);
solve(i);
// fa[root] = root;
// check(root);
}
// printf("hh\n");
bfs(root);
// printf("%d\n", num[root]);
}
return 0;
}
1124
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 25;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
map<string, int> mp;
int main() {
int m, n, s;
while(~scanf("%d %d %d", &m, &n, &s)) {
int won = s;
int all = 0;
mp.clear();
for(int i = 1, j = 1; i <= m; ++i) {
char s[10]; scanf("%s", s);
if(j == won) {
if(mp.find(s) == mp.end()) printf("%s\n", s), won += n, all ++;
else j --;
mp[s] = 1;
}
j++;
}
if(!all) printf("Keep going...\n");
}
return 0;
}
1125 讲道理我没有读懂题之前 = =我以为在你们选几个组成不就行了,直接选两个最大的
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e4+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int a[N];
int main() {
int n;
while(~scanf("%d", &n)) {
for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
sort(a, a + n);
int ans = a[0];
for(int i = 1; i < n; ++i) {
ans = (ans + a[i]) / 2;
}
printf("%d\n", ans);
}
return 0;
}
1126需先判断下图的连通性
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 505;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
struct Node{
int to, nx;
}E[N*N*2];
int head[N], tot;
int vis[N];
void add(int fr, int to) {
E[tot].to = to; E[tot].nx = head[fr]; head[fr] = tot ++;
}
void dfs(int x) {
for(int i = head[x]; ~i; i = E[i].nx) {
int to = E[i].to;
if(!vis[to]) {
vis[to] = 1;
dfs(to);
}
}
}
int in[N];
int main() {
int n, m;
while(~scanf("%d %d", &n, &m)) {
memset(in, 0, sizeof(in));
memset(vis, 0, sizeof(vis));
memset(head, -1, sizeof(head)); tot = 0;
for(int i = 0; i < m; ++i) {
int a, b; scanf("%d %d", &a, &b);
add(a, b); add(b, a);
in[a] ++; in[b] ++;
}
vis[1] = 1;
dfs(1);
int fl = 1;
for(int i = 1; i <= n; ++i) {
if(!vis[i]) {
fl = 0; break;
}
}
int odd = 0; int even = 0;
for(int i = 1; i <= n; ++i) {
if(in[i] % 2 == 0) even ++;
else odd ++;
}
for(int i = 1; i <= n; ++i) {
if(i != 1) printf(" ");
printf("%d", in[i]);
} printf("\n");
if(odd == 0 && fl) printf("Eulerian\n");
else if(odd == 2 && fl) printf("Semi-Eulerian\n");
else printf("Non-Eulerian\n");
}
return 0;
}
1127
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 35;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int in[N];
int post[N];
map<int, int> L;
map<int, int> R;
int solve(int LL, int RR, int l, int r) {
if(l > r) return 0;
else if(l == r) return post[l];
int tag = post[r];
int po = 0;
for(int i = LL; i <= RR; ++i) {
if(in[i] == tag) {
po = i; break;
}
}
int _po = l + (po-1-LL);
L[tag] = solve(LL, po-1, l, _po);
R[tag] = solve(po+1, RR, _po+1, r-1);
return tag;
}
void bfs(int x) {
queue<int> Q;
Q.push(x);
int fl = 1;
while(!Q.empty()) {
vector<int> vc;
int ed = Q.size();
for(int i = 0; i < ed; ++i) {
int po = Q.front(); Q.pop();
vc.push_back(po);
if(L[po]) Q.push(L[po]);
if(R[po]) Q.push(R[po]);
}
if(fl) for(int i = vc.size()-1; i >= 0; --i) {
if(vc[i] != x) printf(" ");
printf("%d", vc[i]);
}else for(int i = 0; i < vc.size(); ++i) {
if(vc[i] != x) printf(" ");
printf("%d", vc[i]);
}
fl ^= 1;
}
printf("\n");
}
int main() {
int n;
while(~scanf("%d", &n)) {
for(int i = 1; i <= n; ++i) {
scanf("%d", &in[i]);
}
for(int i = 1; i <= n; ++i) scanf("%d", &post[i]);
int root = solve(1, n, 1, n);
bfs(root);
}
return 0;
}
1128
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1005;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int dia1[N*2];
int row[N];
int dia2[N*2];
int main() {
int k;
while(~scanf("%d", &k)) {
for(int i = 1; i <= k; ++i) {
int a; scanf("%d", &a);
int fl = 1;
for(int j = 1; j <= a; ++j) {
int b; scanf("%d", &b);
int t1 = b; int t2 = b-j + a; int t3 = b+j;
if(row[t1] == i|| dia1[t2] == i || dia2[t3] == i ) fl = 0;
row[t1] = i; dia1[t2] = i; dia2[t3] = i;
}
if(fl) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
1129
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 5e4+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
int has[N];
int a[N];
struct Node{
int nu, po;
Node(int a=0, int b=0):nu(a), po(b) {}
bool operator <(const Node &T) const {
if(nu != T.nu) return nu > T.nu;
else return po < T.po;
}
};
set<Node> st;
set<Node> ::iterator it;
int main() {
int n, k;
while(~scanf("%d %d", &n, &k)) {
st.clear();
memset(has, 0, sizeof(has));
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
has[a[1]] ++;
st.insert(Node(has[a[1]], a[1]));
for(int i = 2; i <= n; ++i) {
printf("%d: ", a[i]);
int cnt = 0;
for(it = st.begin(); it != st.end(); ++it) {
if(it != st.begin()) printf(" ");
printf("%d", (*it).po);
cnt ++;
if(cnt >= k) break;
}
printf("\n");
has[a[i]] ++;
it = st.find(Node(has[a[i]]-1, a[i]) );
if( it != st.end() ) st.erase(it), st.insert(Node(has[a[i]], a[i]));
else {
st.insert(Node(has[a[i]], a[i]));
if(st.size() > k) st.erase(--st.end());
}
}
}
return 0;
}
1030
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 25;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
char num[N][15];
int dep[N];
int root;
int L[N], R[N];
void dfs(int x) {
if(x != root && L[x] + R[x]) printf("(");
if(L[x]) dfs(L[x]);
printf("%s", num[x]);
if(R[x]) dfs(R[x]);
if(x != root && L[x] + R[x]) printf(")");
}
int main() {
int n;
while(~scanf("%d", &n)) {
for(int i = 1; i <= n; ++i) {
char b[10], c[10];
scanf("%s %s %s", num[i], b, c);
int tt;
if(b[0] != '-') {
sscanf(b, "%d", &tt);
L[i] = tt, dep[tt] ++;
}
if(c[0] != '-') {
sscanf(c, "%d", &tt);
R[i] = tt; dep[tt] ++;
}
}
for(int i = 1; i <= n; ++i) {
if(!dep[i]) {
root = i;
dfs(i);
break;
}
}
printf("\n");
}
return 0;
}
1031 最后一题还是花了一点时间,简单来说就是最短路即可,但是中间处理还是有点难的
#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 105;
const int M = 1e5+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y)
map<int, int> nam;
map<int, int> ::iterator it;
int _nam[M];
vector<int> input[N];
int n;
int tol;
struct Node{
int nx, to, ty;
}E[M*10];
int head[M], tot;
void add(int fr, int to, int ty) {
E[tot].to = to; E[tot].nx = head[fr]; E[tot].ty = ty; head[fr] = tot++;
}
struct Hode{
int po, di, ti, ty;
Hode(int a=0, int b=0, int c=0, int d=0):po(a), di(b), ti(c), ty(d) {}
bool operator < (const Hode & T) const{
if(di != T.di) return di > T.di;
else return ti > T.ti;
}
};
pair<int, int> pre[M]; int vis[M];
int dis[M], tim[M];
vector<pair<int, int> > ans;
void dfs(int x, int s) {
// printf("%d %d\n", x, _nam[x]);
if(x == s) {
return ;
}
dfs(pre[x].first, s);
ans.push_back(MP(x, pre[x].second));
}
void dij(int s, int t) {
// printf("%d %d\n", s, t);
for(int i = 1; i <= tol; ++i) {
vis[i] = 0; dis[i] = INF; tim[i] = INF;
}
dis[s] = 0; tim[s] = 0;
priority_queue<Hode> Q;
Q.push(Hode(s, dis[s], tim[s], INF));
while(!Q.empty()) {
int po = Q.top().po; int ty = Q.top().ty; Q.pop();
if(vis[po]) continue;
vis[po] = 1;
for(int i = head[po]; ~i; i = E[i].nx) {
int to = E[i].to;
int tt = ty != E[i].ty;
if(dis[to] > dis[po] + 1) {
dis[to] = dis[po] + 1;
tim[to] = tim[po] + tt;
pre[to] = MP(po, E[i].ty);
Q.push(Hode(to, dis[to], tim[to], E[i].ty));
}else if(dis[to] == dis[po] + 1 && tim[to] > tim[po] + tt ) {
tim[to] = tim[po] + tt;
pre[to] = MP(po, E[i].ty);
Q.push(Hode(to, dis[to], tim[to], E[i].ty));
}
}
}
ans.clear();
dfs(t, s);
printf("%d\n", dis[t]);
int fr = s;
ans.push_back(MP(INF, INF));
for(int i = 1; i < ans.size(); ++i) {
if(ans[i].second != ans[i-1].second) {
printf("Take Line#%d from %04d to %04d.\n", ans[i-1].second, _nam[fr], _nam[ans[i-1].first]);
fr = ans[i-1].first;
}
}
}
int main() {
while(~scanf("%d", &n)) {
memset(head, -1, sizeof(head)); tot = 0;
for(int i = 1; i <= n; ++i) {
int m; scanf("%d", &m);
input[i].push_back(m);
for(int j = 0; j < m; ++j) {
int b; scanf("%d", &b);
input[i].push_back(b);
nam[b] ++;
}
}
tol = 0;
for(it = nam.begin(); it != nam.end(); ++it) {
nam[it->first] = ++tol;
_nam[tol] = it->first;
}
// for(int i = 1; i <= tol; ++i) printf("%d:%d ", _nam[i], nam[_nam[i]]); printf("\n");
for(int i = 1; i <= n; ++i) {
for(int j = 2; j < input[i].size(); ++j) {
add(nam[input[i][j]], nam[input[i][j-1]], i); add(nam[input[i][j-1]], nam[input[i][j]], i);
}
}
int m; scanf("%d", &m);
while(m --) {
int a, b; scanf("%d %d", &a, &b);
dij(nam[a], nam[b]);
}
}
return 0;
}
pat1121-1131的更多相关文章
- BZOJ 1131: [POI2008]Sta
Description 一棵树,问以那个节点为根时根的总和最大. Sol DFS+树形DP. 第一遍统计一下 size 和 d. 第二遍转移根,统计答案就行了. Code /************* ...
- cdoj 1131 男神的礼物 区间dp
男神的礼物 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/1131 Descr ...
- 九度OJ 1131 合唱队形 -- 动态规划(最长递增子序列)
题目地址:http://ac.jobdu.com/problem.php?pid=1131 题目描述: N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学不交换位置就能排成合 ...
- BZOJ 1131: [POI2008]Sta( dfs )
对于一棵树, 考虑root的答案向它的孩子转移, 应该是 ans[son] = (ans[root] - size[son]) + (n - size[son]). so , 先 dfs 预处理一下, ...
- 1131: [POI2008]Sta
1131: [POI2008]Sta Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 783 Solved: 235[Submit][Status] ...
- CJOJ 1131 机器分配 / Luogu 2066 机器分配 (动态规划)
CJOJ 1131 机器分配 / Luogu 2066 机器分配 (动态规划) Description Luogu: 总公司拥有高效设备M台,准备分给下属的N个分公司.各分公司若获得这些设备,可以为国 ...
- PAT甲级1131. Subway Map
PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...
- hdu 1130,hdu 1131(卡特兰数,大数)
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- BZOJ 1131 [POI2008]Sta(树形DP)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1131 [题目大意] 给出一个N个点的树,找出一个点来,以这个点为根的树时,所有点的深度 ...
- 51nod 1131 数列
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1131 1131 覆盖数字的数量 基准时间限制:1 秒 空间限制:1310 ...
随机推荐
- 夏令营提高班上午上机测试 Day 4 解题报告
我要是没记错的话,今天的题难度算挺适中的. *标程来自高天宇哥哥 T1:小G的字符串 题目描述 有一天,小 L 给小 G 出了这样一道题:生成一个长度为 n 的.全由小写英文字母构成的字符串,只能使用 ...
- InnoDB索引
名词解释 clustered index(聚集索引) 对(primary key)主键索引的一种表述.InnoDB表存储是基于primary key列来组织的,这样做可以加快查询和排序速度.为了获得最 ...
- ECMAScript 6 笔记(二)
ES6中的基本扩展 一.字符串的扩展 1. 字符的Unicode表示法 用两个双字节的形式表达字符时,如果直接在\u后面跟上超过0xFFFF的数值(比如\u20BB7),JavaScript会理解成\ ...
- 开发板访问linux方法
1.使用网线分别将 PC 机与开发板连接到交换机. 2.保证 windows能 ping通 Linux. 2.1.关闭 windows 系统中的其他网络连接,只保留用来和交换机连接的网卡. 2.2.网 ...
- Windows 定时任务对数据库进行操作
定时对数据库进行操作可以用mysql的event事件来完成,但是只有mysql5.1后的才支持,所以有一定的局限性,也可以通过其他的mysql管理软件实现,而我发现Windows本身就有个定时任务的功 ...
- python爬虫(7)——BeautifulSoup
今天介绍一个非常好用的python爬虫库--beautifulsoup4.beautifulsoup4的中文文档参考网址是:http://beautifulsoup.readthedocs.io/zh ...
- CocosCreator游戏开发---菜鸟学习之路(一)
PS(废话): 辞职后在家好久好久了,久到经济不允许了,接着就准备再次出去找工作了,然而工作哪有那么好找,特别是像我这种菜鸟.而且我还准备转行,准备去做游戏,技能等级接近于0,那工作就更难找了.既然如 ...
- Treap-平衡树学习笔记
平衡树-Treap学习笔记 最近刚学了Treap 发现这种数据结构真的是--妙啊妙啊~~ 咳咳.... 所以发一发博客,也是为了加深蒟蒻自己的理解 顺便帮助一下各位小伙伴们 切入正题 Treap的结构 ...
- Jenkins gitlab vue,angular,react 自动化构建【原】
大致思路,(本篇主要讲vue ,当然了 angular react 也是一样配置) ,转发请注明原链接,谢谢 :) 1. 服务器上面配置jenkins (安装配置,不介绍) 2.新建item 自由风格 ...
- hdu 1207 四柱汉诺塔
递推,汉诺塔I的变形. 这题真心没想到正确解法,越想越迷糊.这题看了别人题解过得,以后还是自己多想想,脚步太快并非好事. 贴上分析: 分析:设F[n]为所求的最小步数,显然,当n=1时,F[n]= ...