啊啊啊啊啊啊啊啊啊,目睹A->CⅠA全过,最终fstwaA,C;23333333

A题:

题意:

就是分成相等的m堆,每堆有两个位置上的值相加。

思路:

fst在sum可能不是偶数,先*2/n;。。。。。。。。。。。。。。哭死。。

code:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-6;
const double pi=acos(-1.0);
const int mod=998244353;
const int INF=0x3f3f3f3f; const int N=1e2+10; int a[N];
bool vis[N];
int n; int main()
{
cin>>n;
int sum=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
memset(vis,0,sizeof(vis));
int x=sum*2/n;
for(int i=1;i<=n;i++){
if(!vis[i])
{
printf("%d ",i);
vis[i]=1;
for(int j=1;j<=n;j++)
{
if(!vis[j]){
if((a[i]+a[j])==x)
{
printf("%d\n",j);
vis[j]=1;
break;
}
}
}
}
} }

C题:

题意就是求一个最短连续区间长度包含给定字符串的所有种类。

思路:写挫了。。。。

code:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-6;
const double pi=acos(-1.0);
const int mod=998244353;
const int INF=0x3f3f3f3f; const int N=1e5+10; char s[N];
bool v1[N];
int v2[N];
int p1,p2; int main()
{
int len;
scanf("%d",&len);
scanf("%s",s);
int sum;
int x;
sum=0;
memset(v1,0,sizeof(v1));
for(int i=0;i<len;i++){
x=s[i];
if(!v1[x]){
sum++;
v1[x]=1;
}
}
memset(v2,0,sizeof(v2));
int ans=INF;
int num=0;
int flag=0;
p1=p2=0;
num=0;
while(1)
{
flag=0;
while(num<sum){
if(p2==len)
break;
x=s[p2];
if(!v2[x])
num++;
v2[x]++;
p2++;
flag=1;
// printf("p2=%d\n",p2);
}
while(num==sum){
ans=min(ans,p2-p1);
x=s[p1];
v2[x]--;
if(!v2[x])
num--;
p1++;
flag=1;
// printf("p1=%d\n",p1);
}
if(!flag)
break;
}
printf("%d\n",ans);
return 0;
}

Codeforces Round #364 (Div. 2)【A,C】的更多相关文章

  1. C. Edgy Trees Codeforces Round #548 (Div. 2) 【连通块】

    一.题面 here 二.分析 这题刚开始没读懂题意,后来明白了,原来就是一个数连通块里点数的问题.首先在建图的时候,只考虑红色路径上的点.为什么呢,因为为了不走红色的快,那么我们可以反着想只走红色的路 ...

  2. Codeforces Round #592 (Div. 2)【C题】{补题ING}

    思路:x,y,z肯定不为负数xw+dy=p,直接枚举系数较小的y即可,y的范围:y<w,因为大于w的时候,不如去增加x,这样x+y的和还能保持尽可能小. /* x*w+y*d=p; x*w+(K ...

  3. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  4. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  5. Codeforces Round #435 (Div. 2)【A、B、C、D】

    //在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...

  6. Codeforces Round #434 (Div. 2)【A、B、C、D】

    Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...

  7. Codeforces Round #441 (Div. 2)【A、B、C、D】

    Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...

  8. Codeforces Round #440 (Div. 2)【A、B、C、E】

    Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...

  9. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

随机推荐

  1. 第04章-VTK基础(3)

    [译者:这个系列教程是以Kitware公司出版的<VTK User's Guide -11th edition>一书作的中文翻译(出版时间2010年,ISBN: 978-1-930934- ...

  2. Spring4+SpringMVC+Hibernate4整合入门与实例

    配置web.xml <? xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&q ...

  3. HTML页面底部无用留白

    HTML页面底部无用留白,可以再footer样式中加入: overflow: hidden; 如有错误,请您指正~

  4. hiberinate二级缓存

    hibernate.cfg.xml配置 <!-- 二级缓存类型 --> <property name="hibernate.cache.region.factory_cla ...

  5. 2016/05/27 php上传文件常见问题总结

    php上传文件常见问题总结 投稿:hebedich 字体:[增加 减小] 类型:转载 时间:2015-02-03我要评论 这篇文章主要介绍了php上传文件常见问题总结,基本上经常碰到的问题的处理都列了 ...

  6. Golang 现有的哲学中,要求你尽量手工处理所有的错误返回

    更优雅的 Golang 错误处理 - Go语言中文网 - Golang中文社区 https://studygolang.com/articles/9407

  7. the hard problems when writing a great connector; type cohersion, data partitioning and data locality to name a few

    http://rosslawley.co.uk/introducing-a-new=mongodb-spark-connector/

  8. C# 软件实现远程桌面调用

    1.https://www.codeproject.com/Articles/19836/Palantir-Remote-Desktop-Manager codeproject项目 2.http:// ...

  9. leetcode 681. Next Closest Time

    Given a time represented in the format "HH:MM", form the next closest time by reusing the ...

  10. 在U-Boot中添加自定义命令以实现自动下载程序【转】

    本文转载自:https://gaomf.cn/2016/06/26/%E5%9C%A8U-Boot%E4%B8%AD%E6%B7%BB%E5%8A%A0%E8%87%AA%E5%AE%9A%E4%B9 ...