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. contab的使用方法

    linux 系统则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的计划性工作,因此这个系统服务是默认启动的.另 外, 由于使用者自己也可以设置计划任务,所以, ...

  2. JPA @MappedSuperclass注解

    该注解只能引用于类上,使用该注解的类将不是一个完整的类,不会映射到数据库的表中,但是该类的属性会映射到其子类的数据库字段中 @MappedSuperclass注解使用在父类上面,是用来标识父类的作用 ...

  3. 关于vuex的理解

    刚开始学vue的时候,看到很多项目都有用vuex,抱着一种好奇的心态去看下vuex的官方文档,如下: Vuex官方文档 Vuex 是什么?Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式 ...

  4. ibatis常用16条SQL语句

    (1) 输入参数为单个值 <delete id="com.fashionfree.stat.accesslog.deleteMemberAccessLogsBefore" p ...

  5. 「 HDU P3336 」 Count the string

    题目大意 给出一个长度为 $n$ 的字符串 $s$ 要求你求出 $s$ 的每一个前缀在 $s$ 中出现的次数之和.$n\le 200000$. 解题思路 暴力的对每一个前缀进行一次匹配,求出出现次数后 ...

  6. FileWriter实现从一个文件中读取内容并写到另一个文件中

    FileWriter和FileOutputStream都是向文件写内容,区别是前台一次写一个字符,后者一次写一个字节 package com.janson.day20180827; import ja ...

  7. Shiro_DelegatingFilterProxy

    1.DelegatingFilterProxy实际上是Filter的一个代理对象.默认情况下,Spring会到IOC容器中查找与<filter-name>对应的filter bean.也可 ...

  8. 解决maven无法加载本地lib/下的jar包问题(程序包XXX不存在)

    这次一个项目用到maven编译,我在本地开发的时候jar包都是放在WEB-INF/lib目录下,通过 BuildPath将jar包导入,然后用MyEclipse中的:maven package命令打成 ...

  9. ZOJ 3201 树形背包问题

    题目大意: 0~n-1号这n个点,每个点有个权值,由无向边形成了一棵树,希望在这棵树上找到一棵长为m的子树使总的权值最小 基本的树形背包问题 令dp[u][j] 表示u号节点对应子树中有j个节点所能得 ...

  10. hdu3450

    分析:首先要知道有递推公式dp[i] = Sigma(dp[j]),dp[i]表示第i个数结尾的完美子序列的个数,|a[i] - a[j]| <= d,j<i.直接这样做的时间复杂度为n^ ...