A 出题人不给样例解释。。。具体程序

#include<bits/stdc++.h>
using namespace std;
int n;
char s[];
int main()
{
scanf("%d%s", &n, s + );
int ans = , tot = ;
for(int i = ; i <= n; ++i)
{
if(s[i] == '') ++tot;
else
{
ans = ans * + tot;
tot = ;
}
}
printf("%d\n", ans * + tot);
return ;
}

B 枚举每个点填上黑子,然后判断

#include<bits/stdc++.h>
using namespace std;
const int dx[] = {, , -, -}, dy[] = {, , , };
int n;
char Map[][];
bool check()
{
for(int i = ; i <= ; ++i)
for(int j = ; j <= ; ++j) if(Map[i][j] == 'X')
{
for(int k = ; k < ; ++k)
{
int xx = i, yy = j;
bool flag = true;
for(int l = ; l < ; ++l)
{
xx += dx[k], yy += dy[k];
if(Map[xx][yy] != 'X')
{
flag = false;
break;
}
}
if(flag) return true;
}
}
return false;
}
int main()
{
memset(Map, 'O', sizeof(Map));
for(int i = ; i <= ; ++i)
scanf("%s", Map[i] + );
for(int i = ; i <= ; ++i)
for(int j = ; j <= ; ++j) if(Map[i][j] == '.')
{
char c = Map[i][j];
Map[i][j] = 'X';
if(check())
{
puts("YES");
return ;
}
Map[i][j] = c;
}
puts("NO");
return ;
}

C 贪心,不够就乘2,每次和a取大

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
int n, ans;
ll k;
ll a[N];
int main()
{
scanf("%d%d", &n, &k);
for(int i = ; i <= n; ++i) scanf("%lld", &a[i]);
sort(a + , a + n + );
for(int i = ; i <= n; ++i)
{
while(k < (a[i] + 1ll) / 2ll)
{
++ans;
k = 2ll * k;
}
if(k >= (a[i] + 1ll) / 2ll) k = max(k, a[i]);
}
printf("%d\n", ans);
return ;
}

D 贪心,能互相交换肯定能换成那个目标串,所以看现在缺少目标串哪个元素就加上

#include<bits/stdc++.h>
using namespace std;
const int N = ;
char s[N], t[N];
int cnt[], cnt1[];
int main()
{
scanf("%s%s", s + , t + );
int len1 = strlen(t + ), len2 = strlen(s + );
for(int i = ; i <= len1; ++i) ++cnt[t[i] - 'a'];
for(int i = ; i <= len2; ++i) if(s[i] != '?')
++cnt1[s[i] - 'a'];
for(int i = ; i <= len2; ++i)
{
bool flag = false;
if(s[i] == '?')
{
int pos = ;
for(int j = ; j < ; ++j) if(cnt1[j] < cnt[j])
{
++cnt1[j];
flag = true;
pos = j;
break;
}
if(!flag)
{
for(int j = ; j < ; ++j) cnt1[j] -= cnt[j];
for(int j = ; j < ; ++j) if(cnt1[j] < cnt[j])
{
++cnt1[j];
pos = j;
break;
}
}
printf("%c", (char)(pos + 'a'));
}
else printf("%c", s[i]);
}
return ;
}

E 贪心,证明待填

#include<bits/stdc++.h>
using namespace std;
const int N = ;
int n, m;
priority_queue<int> q;
vector<int> G[N];
int c[N], d[N];
int main()
{
scanf("%d%d", &n, &m);
for(int i = ; i <= m; ++i)
{
int u, v;
scanf("%d%d", &u, &v);
G[v].push_back(u);
++d[u];
}
for(int i = ; i <= n; ++i) if(!d[i]) q.push(i);
for(int i = n; i; --i)
{
int x = q.top();
q.pop();
c[x] = i;
for(int j = ; j < G[x].size(); ++j)
{
int v = G[x][j];
--d[v];
if(!d[v]) q.push(v);
}
}
for(int i = ; i <= n; ++i) printf("%d ", c[i]);
return ;
}

F dp dp[i]=min(dp[j-1]+calc(j, i)),calc可以先预处理lcp,然后暴力枚举串的长度,看是否符合 这个跑不过去,要4s

#include<bits/stdc++.h>
using namespace std;
const int N = ;
int n;
int dp[N][N], f[N], sum[N];
char s[N];
int getlen(int x)
{
int ret = ;
while(x)
{
++ret;
x /= ;
}
return ret;
}
int main()
{
scanf("%s", s + );
n = strlen(s + );
for(int i = n; i; --i)
for(int j = n; j >= i; --j)
if(s[i] == s[j])
dp[i][j] = dp[i + ][j + ] + ;
memset(f, 0x3f3f, sizeof(f));
f[] = ;
for(int i = ; i <= ; ++i) sum[i] = sum[i / ] + ;
for(int i = ; i <= n; ++i)
for(int j = i; j; --j)
for(int k = i - j + ; k > && dp[k][i - j + ] >= j; k -= j)
f[i] = min(f[i], f[k - ] + j + sum[(i - k + ) / j]);
printf("%d\n", f[n]);
return ;
}

G dfs 思路很好,把第一个变成黑点的点作为根,然后预处理出每个点到根的最小值,每次查询直接拿自己的最小值和上次答案比较,因为上次的答案这次肯定也能用,更新就是把当前的最小值和ans取min

#include<bits/stdc++.h>
using namespace std;
const int N = ;
int opt, x, n, q, last, ans = << ;
int up[N];
vector<int> G[N];
void dfs(int u, int last)
{
for(int i = ; i < G[u].size(); ++i)
{
int v = G[u][i];
if(v == last) continue;
up[v] = min(v, up[u]);
dfs(v, u);
}
}
int main()
{
scanf("%d%d", &n, &q);
for(int i = ; i < n; ++i)
{
int u, v;
scanf("%d%d", &u, &v);
G[u].push_back(v);
G[v].push_back(u);
}
scanf("%d%d", &opt, &x);
x = (x + last) % n + ;
up[x] = x;
dfs(x, );
q--;
while(q--)
{
scanf("%d%d", &opt, &x);
x = (x + last) % n + ;
if(opt == ) ans = min(ans, up[x]);
if(opt == )
{
printf("%d\n", min(ans, up[x]));
last = min(ans, up[x]);
}
}
return ;
}

codeforces educational round 25的更多相关文章

  1. Codeforces Beta Round #25 (Div. 2 Only)

    Codeforces Beta Round #25 (Div. 2 Only) http://codeforces.com/contest/25 A #include<bits/stdc++.h ...

  2. Codeforces Educational Round 33 题解

    题目链接   Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> ...

  3. Codeforces Educational Round 92 赛后解题报告(A-G)

    Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...

  4. [CodeForces]Educational Round 52

    幸好我没有打这场,我VP的时候在C题就卡死了,我果然还是太菜了. A Vasya and Chocolate 题意:一个巧克力\(c\)元,买\(a\)赠\(b\),一共有\(n\)元,问能买几个巧克 ...

  5. codeforces水题100道 第十七题 Codeforces Beta Round #25 (Div. 2 Only) A. IQ test (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/25/A题意:在n个书中找到唯一一个奇偶性和其他n-1个数不同的数.C++代码: #include ...

  6. Codeforces Educational Round 37

    Solved   CodeForces 920A Water The Garden   Solved   CodeForces 920B Tea Queue   Solved   CodeForces ...

  7. Codeforces Educational round 58

    Ediv2 58 随手AK.jpg D 裸的虚树,在这里就不写了 E 傻逼贪心?这个题过的比$B$都多.jpg #include <cstdio> #include <algorit ...

  8. Codeforces Educational Round 57

    这场出题人好像特别喜欢998244353,每个题里都放一个 A.Find Divisible 考察选手对输入输出的掌握 输出l 2*l即可(为啥你要放这个题,凑字数吗 #include<cstd ...

  9. Codeforces Beta Round #25 (Div. 2)--A. IQ test

    IQ test time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

随机推荐

  1. BZOJ5314: [Jsoi2018]潜入行动 (树形DP)

    题意:一棵树选择恰好k个结点放置监听器 每个监听器只能监听相邻的节点 问能使得所有节点被监听的种类数 题解:反正就是很well-known的树形DP了 至于时间复杂度为什么是nk 不会不学 很好想到四 ...

  2. UVA - 1601 The Morning after Halloween (双向BFS&单向BFS)

    题目: w*h(w,h≤16)网格上有n(n≤3)个小写字母(代表鬼).要求把它们分别移动到对应的大写字母里.每步可以有多个鬼同时移动(均为往上下左右4个方向之一移动),但每步结束之后任何两个鬼不能占 ...

  3. Linux学习笔记记录(二)

  4. 52.基于doc value正排索引的聚合内部原理

    主要知识点: 本节没有太懂,以后复习时补上       聚合分析的内部原理是什么????aggs,term,metric avg max,执行一个聚合操作的时候,内部原理是怎样的呢?用了什么样的数据结 ...

  5. Django-Rest framework中文翻译-Request

    REST framework的Request类扩展自标准的HttpRequest,增加了REST framework灵活的请求解析和请求验证支持. 请求解析 REST framework的Reques ...

  6. Wind rotor states

    test test Table of Contents 1. Wind rotor states 1.1. Turbulent Wake State 1.2. Vortex Ring State 1. ...

  7. 浅谈对java-GC的理解

    前段时间,一个线上项目忽然很卡,通过监控,发现内存很高,果不其然在几个小时后,OOM.虽说有人很快处理好了.但我还是想站在我的角度,对这件事发表一下自己的观点. 内存溢出,多发生在项目上线后,而且在系 ...

  8. hadoop full cluster 改为伪分布

    https://hadoop.apache.org/docs/r2.7.6/hadoop-project-dist/hadoop-common/SingleCluster.html#Pseudo-Di ...

  9. RCC 2014 Warmup (Div. 2) 蛋疼解题总结

    A. Elimination time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  10. JVM即时编译(JIT)

    Java解释执行过程: 代码装入-代码校验-代码执行 Java字节码的执行方式分为两种:即使编译方式和解释执行方式.即时编译是值解释器先将字节码编译成机器码,然后执行该机器码.解释执行的方式是指解释器 ...