Codeforces Round #364 (Div. 2)【A,C】
啊啊啊啊啊啊啊啊啊,目睹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】的更多相关文章
- C. Edgy Trees Codeforces Round #548 (Div. 2) 【连通块】
一.题面 here 二.分析 这题刚开始没读懂题意,后来明白了,原来就是一个数连通块里点数的问题.首先在建图的时候,只考虑红色路径上的点.为什么呢,因为为了不走红色的快,那么我们可以反着想只走红色的路 ...
- 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 ...
- Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #435 (Div. 2)【A、B、C、D】
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...
- 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. 题解:答案就是 ...
- Codeforces Round #441 (Div. 2)【A、B、C、D】
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...
- Codeforces Round #440 (Div. 2)【A、B、C、E】
Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...
- Codeforces Round #439 (Div. 2)【A、B、C、E】
Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...
随机推荐
- 批量修改文件权限 和所有者 chown nobody:nobody * -R chmod 775 * -R
chown nobody:nobody * -R chmod 775 * -R
- MongoDB:数据模型介绍
在MongoDB的数据有灵活的模式.不像SQL数据库,(SQL数据库)要求你必须在插入数据之前决定和声明一个表的模式.MongoDB的集合不强制文档的结构.这个灵活性有利于文档到实体或对象的映射. 每 ...
- [ACM] POJ 3253 Fence Repair (Huffman树思想,优先队列)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 25274 Accepted: 8131 Des ...
- Hadoop教程(一)
英文原文:cloudera,编译:ImportNew – Royce Wong Hadoop从这里开始!和我一起学习下使用Hadoop的基本知识,下文将以Hadoop Tutorial为主体带大家走一 ...
- BZOJ 3732 Network 最小瓶颈路
题目大意:给出一个无向边,非常多询问,问x,y两地之间的最长路最短是多少. 思路:乍一看好像是二分啊. 的确这个题二分能够做.可是时间会慢非常多,有的题直接就T掉(NOIP2013货车运输). 事实上 ...
- The most widely used name server software: BIND
https://www.isc.org/downloads/bind/ The most widely used name server software: BIND BIND is open sou ...
- String、StringBilder和StringBuffer之间的区别
1.三者在执行速度方面的比较:StringBuilder > StringBuffer > String 2.String <(StringBuffer,StringBuild ...
- NPOI实现Excel导入
导入功能实现: ]; GetExtensionsFromFileStream(file.InputStream); using NPOI.XSSF.UserModel; public List< ...
- WPF绑定各种数据源之object数据源
一.WPF绑定各种数据源索引 WPF 绑定各种数据源之Datatable WPF绑定各种数据源之object数据源 WPF绑定各种数据源之xml数据源 WPF绑定各种数据源之元素控件属性 Bindin ...
- Spark学习笔记:(一)入门 glance
参考: http://spark.apache.org/docs/latest/quick-start.html 其它资料: http://mojijs.com/2015/04/190845/i ...