Codeforces Round #390 (Div. 2)
时隔一个月重返coding……
期末复习了一个月也不亏 倒是都过了……
就是计组61有点亏 复变68也太低了 其他都还好……
假期做的第一场cf 三道题 还可以……
最后room第三 standing383简直人生巅峰……
看楼上楼下都是两道题的 如果A题不错那么多估计能进前300了吧……
这场倒是把之前两场的分加回来了 开头不错 这个假期争取紫名~
A.Lesha and array splitting
把给定的数组分割成几个区间 要求各个区间和不能为0
一开始没注意到分割之后的区间重新合成之后还是这个区间错了好几发……
具体思路见注释
#include <bits/stdc++.h>
using namespace std; int a[]; int main()
{
int n;
int p = -, sum = ;
scanf("%d",&n);
for (int i = ; i <= n; i ++)
{
scanf("%d",&a[i]);
sum += a[i];
if (a[i] != && p == -)
{
p = i;
}
}
if (p == -)
{//都是零的话肯定不行
puts("NO");
}
else
{
puts("YES");
if (sum != )
{//数列和不为零 那么一个区间就够了
printf("1\n1 %d\n",n);
}
else
{//数列和为零的话 取最前面的分割点就好了
printf("2\n1 %d\n%d %d\n", p, p+, n);
}
}
return ;
}
B.Ilya and tic-tac-toe game
题意就是问该下的人再下一步能不能赢
4x4的格子强行暴力
#include <bits/stdc++.h>
using namespace std; char mp[][],one; int main()
{
int nx=,no=;
for(int i=; i<; i++)
{
gets(mp[i]);
for(int j=; j<; j++)
{
if(mp[i][j]=='x') nx++;
if(mp[i][j]=='o') no++;
}
}
if(no==nx) one='x';
else one='o';
bool ok=false;
for(int i=; i<; i++)
{
for(int j=; j<; j++)
{
if(mp[i][j]=='.') //这个地方是空的 假如把棋子下在这
{
mp[i][j]=one;
for(int k=; k<; k++)
{
for(int l=; l<; l++)
{
if(k < && mp[k][l] == one && mp[k+][l] == one && mp[k+][l] == one) ok=true;
if(l < && mp[k][l] == one && mp[k][l+] == one && mp[k][l+] == one) ok=true;
}
}
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(mp[][] == one && mp[][] == one && mp[][] == one) ok = true;
if(ok)
{
printf("YES");
return ;
}
else mp[i][j]='.'; //没赢 换个地方下
}
}
}
printf("NO\n");
return ;
}
C.Vladik and chat
是个大模拟 还没弄明白……
D.Fedor and coupons
数据结构题
给你n个区间 选择k个求最长交集
自己做没做出来 和别人交流了一下才知道是个堆 现学现卖了一发
写了一个堆 维护前k大值 假设区间i作为最后一个区间必选
ans=max(前i-1个区间右端点的k-1大值,第i区间右端点的最小值) - 第i个区间左端点
#include<bits/stdc++.h>
using namespace std; const int maxn=3e5+; struct A
{
int x, y, id;
} a[maxn]; bool cmp(A x,A y)
{
return x.y == y.y ? x.x < y.x : x.y > y.y;
} priority_queue<int> q;
int ans = , r = -,n, k; void solve() //优先队列维护k大值
{
q.push(-2e9);
for (int i = ; i < n; i ++)
{
if (q.size() == k)
{
int l = max(q.top(), a[i].x);
if (a[i].y - l + >= ans)
{
ans = a[i].y - l + ;
r = a[i].y;
}
}
q.push(a[i].x);
if (q.size() > k)
{
q.pop();
}
}
} void print()
{
if(ans)
{
int l = r - ans + ;
for (int i = ; k > ; i ++)
{
if (a[i].x <= l && a[i].y >= r)
{
k --;
printf("%d ",a[i].id);
}
}
}
else
{
for (int i = ; i < k; i ++)
{
printf("%d ",a[i].id);
}
}
} int main()
{
scanf("%d%d",&n,&k);
for (int i = ; i < n; i ++)
{
scanf("%d%d",&a[i].x,&a[i].y);
a[i].id = i + ;
}
sort(a, a + n, cmp); //按区间边界排序
solve();
printf("%d\n",ans);
print();
return ;
}
/* */
E.Dasha and cyclic table
没看懂……
巨巨们讨论的热火朝天 我却啥都听不懂……
等能听懂他们说啥应该就有很大进步了吧……
Codeforces Round #390 (Div. 2)的更多相关文章
- Codeforces Round #390 (Div. 2) D. Fedor and coupons(区间最大交集+优先队列)
http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端 ...
- Codeforces Round #390 (Div. 2) C. Vladik and chat(dp)
http://codeforces.com/contest/754/problem/C C. Vladik and chat time limit per test 2 seconds memory ...
- Codeforces Round #390 (Div. 2) A. Lesha and array splitting
http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...
- Codeforces Round #390 (Div. 2) E(bitset优化)
题意就是一个给出2个字符矩阵,然后进行匹配,输出每个位置的匹配的结果 (超出的部分循环处理) 一种做法是使用fft,比较难写,所以没有写 这里使用一个暴力的做法,考虑到一共只出现26个字符 所以使用一 ...
- Codeforces Round #390 (Div. 2) A B C D
这是一场比较难的div2 ... 比赛的时候只出了AB A很有意思 给出n个数 要求随意的把相邻的数合并成任意多数 最后没有为0的数 输出合并区间个数与区间 可以想到0可以合到任何数上并不改变该数的性 ...
- Codeforces Round #390 (Div. 2) D
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring s ...
- Codeforces Round #390 (Div. 2) B
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. ...
- Codeforces Round #390 (Div. 2) A
One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into sev ...
- Codeforces Round #390 (Div. 2) A+B+D!
A. Lesha and array splitting 水题模拟.(0:10) 题意:给你一个n个元素的数组,求能否把这个数组分成若干连续小段,使得每段的和不为0.如有多种解输出任意一个. 思路:搞 ...
随机推荐
- ASP.NET MVC应用程序使用axd格式文件
ASP.NET MVC应用程序使用axd格式文件 axd格式文件,不管是在asp.net还是现在开发asp.net MVC应用程序,都是Insus.NET较喜欢使用的. 因为我们可以虚拟一个在应用程序 ...
- vs2012快速将项目托管到github
vs2012快速将项目托管到github 在VS2012中使用GitHub 注册GitHub账号(DeanZhouLin) https://github.com/ 向GitHub中添加一个仓库(T ...
- HttpTest4Net
HttpTest4Net HttpTest4Net是一款基于C#实现的和HTTP压力测试工具,通过工具可以简单地对HTTP服务进行一个压力测试.虽然VS.NET也集成了压力测试项目,但由于VS自身占用 ...
- Using Ninject in a Web Application
http://aidenweb.co.uk/?p=15 Using Ninject in a Web Application I have been meaning to look at Ninjec ...
- linux的运行级别
一.linux共有七种运行级别,内容如下: 级别0:停机状态,系统默认运行级别如果设为0,将不能正常启动: 级别1:单用户模式,只允许root用户对系统进行维护: 级别2:多用户模式,但没有NFS(h ...
- vijos1004 博弈论
一道挺简单的博弈论题 感觉自己也没有很规范的学过博弈论吧,就是偶尔刷到博弈论的题目,感受一下推导的过程,大概能领悟些什么 我们设2001.11.4必败,推上去,即2001.10.4和2001.11.3 ...
- 网址URL中特殊字符转义编码
网址URL中特殊字符转义编码 字符 - URL编码值 空格 - %20 " - %22 # - %23 % - %25 & - %26 ( - %28 ) - %29 + - %2B ...
- 重拾C
重拾C,一天一点点_10 来博客园今天刚好两年了,两年前开始学编程. 忙碌近两个月,项目昨天上线了,真心不容易,也不敢懈怠,接下来的问题会更多.这两天调试服务器,遇到不少麻烦. 刚出去溜达了一下,晚上 ...
- 企业架构与建模之Archimate视图和视角
企业架构与建模之Archimate视图和视角 3. ArchiMate的视角与视图 创建.维护一个企业架构是一件非常复杂繁琐的事情,因为这项工作需要面对许多背景.利益各异的干系人,对他们所关注的问题进 ...
- CSS属性合写
animation:[[ animation-name ] || [ animation-duration ] || [ animation-timing-function ] || [ animat ...