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. Linux系统安装,组成及开关机

    Linux系统安装,组成及开关机 系统安装 swap分区用于实现虚拟内存,文件系统类型是swap. /分区用于存放包括系统程序和用户数据在内的所有数据,文件系统类型是ext4. 系统组成 Linux内 ...

  2. elk大纲

    一.ELK功能概览 1.检索 2.数据可视化--实时监控(实时刷新) nginx 访问量 ip地区分布图(大数据) 3.zabbix 微信联动报警 4.大数据日志分析平台(基于hadoop) 二.ka ...

  3. 通过HTTP的HEADER完成各种骚操作

    作为一名专业的切图工程师,我从来不care网页的header,最多关心Status Code是不是200.但是HEADER真的很重要啊,客户端从服务器端获取内容,首先就是通过HEADER进行各种沟通! ...

  4. ROS lesson 1

    ROS ROS官网 ROS 简介 ROS 是 Robot Operation System 的简写,并且 他诞生在2000年后,至今有10余年了,运行在 Linux(Ubuntu) 上 ROS 不是 ...

  5. <MyBatis>入门八 工作原理

    1.获取sqlSessionFactory对象 首先拿到全局配置文件的流对象 创建SqlSessionFactoryBuilder对象,并调用build方法,把流传进去 build方法 创建一个XML ...

  6. highcharts图表的常见操作

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  7. 07 Python编码问题

    17) 编码 18) Python3的执行过程 19) 常见编码错误原因 20) 后附一部分编码详细信息(个人总结,有误望指正) 想了解Python3的编码更细致的讲解请参考大王的文章 http:// ...

  8. saltstack(六) saltstack Job管理

    一,简介 Jid: job id 格式为%Y%m%d%H%M%S%f master在下发指令消息时,会附带上产生的jid,minion在接收到指令开始执行时,会在本地的cachedir(默认是/var ...

  9. nginx4win10 文件下载服务器

    默认root是Nginx下目录html. 我们在其目录下新建download目录,然后在该目录下copy几个供下载的文件. 在浏览器输入http://localhost:9001/download/y ...

  10. How Can You Tell the Difference Between LINQ Methods and Query Builder Methods?

    LINQ's method syntax looks very similar to the query builder methods,except for one big difference:t ...