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 ...
随机推荐
- [Oracle] 获取运行计划的各方法总结
总的结论: 一.获取运行计划的6种方法(具体步骤已经在每一个样例的开头凝视部分说明了): 1. explain plan for获取: 2. set autotrace on . 3. stati ...
- 【iOS】KVC 与 KVO
一.KVC与KVO *"KVC":key value Coding(键值编码) *目的:间接的改动或获取对象的属性,减少程序(类与类)之间的耦合度. *"KVO" ...
- 诊断并解决 ORA-4030 错误 (Doc ID 1548826.1)
适用于: Oracle Database - Enterprise Edition - 版本号 8.1.7.4 和更高版本号 本文档所含信息适用于全部平台 用途 怎样诊断 ORA-4030 错误 排错 ...
- HTML页面中点击按钮关闭页面几种方式与取消
1.不带任何提示关闭窗口的js代码 <input type="button" name="close" value="关闭" oncl ...
- JAVA学习之 Model2中的Servlet与.NET一般处理程序傻傻分不清楚
时隔多日,多日合适吗,应该是时隔多月.我又想起了一般处理程序.这都是由于近期在实现的DRP系统中经经常使用到jsp+servlet达到界面与逻辑的分离.servlet负责处理从jsp传回的信息:每当这 ...
- CSS3 Selector
每个前端工程师可能每天都会写一些css,其中选择器是很主要的一部分.但是,大家可能每天写的大多是#id,.class这样的选择器,这并不稀奇,但是如果我们了解并且熟用css3为我们提供的强大并且优雅的 ...
- Hibernate commit() 和flush() 的区别
<<精通Hibernate java对象持久化技术详解>> ,flush()方法进行清理缓存的操作,执行一系列的SQL语句,但不会提交事务;commit()方法会先调用flus ...
- VC++ 对话框下使用工具栏
关于这一技术网上也有很多的记录,下面仅记录我测试OK的代码. 在CXXDlg.h中添加如下成员变量: CToolBar m_ToolBar; CBitmap m_bmpTool; 在CXXDlg ...
- 大整数分解质因数(Pollard rho算法)
#include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> ...
- 前端模块化开发的规范:AMD与CDM
AMD, 异步模块定义. CMD,通用模块规范.