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 ...
随机推荐
- People seldom do what they believe in. They do what is convenient, then repent.
People seldom do what they believe in. They do what is convenient, then repent. 人们很少真正实践他们的理想.他们只做比较 ...
- candy——动态规划
There are N children standing in a line. Each child is assigned a rating value. You are giving candi ...
- python实现的一个简单的网页爬虫
学习了下python,看了一个简单的网页爬虫:http://www.cnblogs.com/fnng/p/3576154.html 自己实现了一个简单的网页爬虫,获取豆瓣的最新电影信息. 爬虫主要是获 ...
- C++ string string string string string string string string string string
一. 初始化 string s1="i love you"; string s2(s1); //把s2初始化为string s1,注意不能写成string s2; s2(s1); ...
- Arduino 网络时钟client
升级! 添加了12h/24h 的开关,还有标准/ 夏令时开关!见步骤7 & 步骤8. 你是否曾想要一个和办公室时间来源全然准确的表? 这就有一个网络的办公时间server,你能够根据它并同步你 ...
- POJ 2524 Ubiquitous Religions (幷查集)
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23090 Accepted: ...
- JRE、JDK、JVM区别和联系
首先说Java编程语言,它是一门高级编程语言,具体由谁何时创建的,读者可以到网上查找相关资料,这里就不再赘述.那么,谈到Java就不得不谈谈JVM.JRE和JDK三者间的区别和联系. JVM:英文全称 ...
- My app status is Ready for Sale but I cannot see my app on the App Store. Why? 为什么审核通过后 appstore中搜不到我的app
这是苹果的官方解答 The following factors could prevent your app from showing up on the App Store: Make sure t ...
- 如何使用Visual Studio构建libiconv
参考博文:How to Build libiconv with Microsoft Visual Studio - CodeProject libiconv源码下载地址:libiconv - GNU ...
- spark集成hivecontext配置
spark版本:spark-1.6.0-bin-hadoop2.6hive版本:hive 1.2.1 1.hive-site.xml<property> <name>hive ...