啊啊啊啊啊啊啊啊啊,目睹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. 为什么一个目录里放超过十个Mp4文件会导致资源管理器和播放程序变卡变慢?

    最近<鬼吹灯之精绝古城>大火,我也下载了剧集放在移动硬盘里. 起初还没事,当剧集超过十个时发现资源管理器变慢了,表现为上方的绿条总是在闪动前进,给文件改名都缓慢无比. 当剧集超过十五个时, ...

  2. OCP47:155

  3. vue - 前置工作 - 目录功能介绍

    一个DEMOS的完整目录(由于GWF问题,我就不一一打开网站一个个去搜索并且解释了)可以去关注:https://www.cnblogs.com/ye-hcj build build.js(本文来自ht ...

  4. VLFeat中SIFT特征点检测

    本代码使用VLFeat库中的函数对一幅图像进行了SIFT检测 需要事先配置好VLFeat和OpenCV,VLFeat的配置参考前一篇博文,OpenCV的配置网上一大堆,自己去百度 #include & ...

  5. Linux性能查看与分析--命令行工具介绍

    本文介绍工作中常用的几个linux性能查看命令:top,sar,vmstat,iostat,pidstat等. 1.top top是最常用的linux性能分析工具,它能够实时的显示系统中各个进程的资源 ...

  6. [转载]CodeIgniter配置之URL

    应该有很多项目中会有这样的情况,通过 http://pc.local 可以访问,若通过 http://localhost/pc/public 则会出现一些图片.样式显示不到,超链接出错的情况,项目的移 ...

  7. Apache Qpid消息通讯模型和消息地址简介

    Broker知识准备 Broker内置两种节点类型:一种是 queue,一种是 topic. 1.  queue 节点能够缓存消息,直到被读取走为止.queue节点满足两个重要的 PTP 通信的特征, ...

  8. 创建Material Design风格的Android应用--应用主题

    本人全部文章首先公布于个人博客,欢迎关注,地址:http://blog.isming.me 昨天正式公布了android 5,同一时候android developer站点也更新了,添加了创建Mate ...

  9. ie9浏览器中h标签的嵌套问题

    ie9中 h1-h6 标签中不能够嵌套h1-h6标签,否则往下看吧. 举个栗子: 我们要实现h1下的两个div实现左右分离,很简单吧? 看看html结构及css吧 <!DOCTYPE html& ...

  10. springboot 项目 docker化部署

    最近公司项目需要docker化,项目所使用的框架是springboot,linux环境.第一次接触docker化方面的技术.做的时候,所接触的新知识比较多,留下此文,以便以后用到的时候快速入手. 修改 ...