http://codeforces.com/contest/961

B题 可以将长度为k的连续区间转化成1 求最大和

解析 简单尺取

 #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <utility>
using namespace std;
const int maxn = 2e5+,maxm = 1e4+;
const int inf = 0x3f3f3f3f,mod = ;
const double epx = 1e-;
typedef long long ll;
const ll INF = 1e18;
const double pi = acos(-1.0);
int n,m,k;
int a[maxn],b[maxn];
int main()
{
cin>>n>>k;
for(int i=;i<=n;i++)
{
cin>>a[i];
}
int sum=;
for(int i=;i<=n;i++)
{
cin>>b[i];
if(b[i])
sum+=a[i];
}
int maxx=-;
int l=,r=,temp=;
while(l<=n-k+)
{
if(r-l<k)
{
if(b[r]==)
temp+=a[r];
r++;
}
else
{
//cout<<l<<" "<<r<<" "<<temp<<endl;
maxx=max(maxx,temp+sum);
if(b[l]==)
sum-=a[l];
l++;
}
}
cout<<maxx<<endl;
}

C题 棋盘分成了大小相同的四块 替换最少的方块  组成一个合格(0,1不相邻)的棋盘

j解析 对于一个合格的棋盘只有两种情况 左上角1 左上角0  四块拼成大棋盘的组合情况有24种 数组范围不大直接每种都跑一边就好了

其实直接枚举6种就好了哪两块左上角为1    C(4,2)

 #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <utility>
using namespace std;
const int maxn = 1e2+,maxm = 1e4+;
const int inf = 0x3f3f3f3f,mod = ;
const double epx = 1e-;
const double pi = acos(-1.0);
typedef long long ll;
const ll INF = 1e18;
int n,m,k,sum;
char a[][maxn][maxn];
char g[*maxn][*maxn];
int vis[*maxn][*maxn];
int dir[][]={{,},{-,},{,},{,-}};
int aa[],xu[][],cnt=;
void dfs(int cur,int n)
{
for(int i=;i<n;i++)
aa[i]=i+cur;
do{
for(int i=;i<n;i++)
xu[cnt][i]=aa[i];
cnt++;
}while(next_permutation(aa,aa+));
}
void DFS(int x,int y,char z)
{
vis[x][y]=;
if((x+y)%==&&g[x][y]!=z)
sum++;
else if((x+y)%==&&g[x][y]==z)
sum++;
for(int i=;i<;i++)
{
int x1=x+dir[i][];
int y1=y+dir[i][];
if(vis[x1][y1]==&&x1>=&&x1<=*n-&&y1>=&&y1<=*n-)
{
DFS(x1,y1,z);
}
}
}
int main()
{
cin>>n;
dfs(,);
int minn=inf;
for(int i=;i<=;i++)
{
for(int j=;j<n;j++)
{
cin>>a[i][j];
}
}
for(int i=;i<cnt;i++)
{
for(int j=;j<;j++)
{
if(j==)
{
for(int k=;k<n;k++)
{
for(int l=;l<n;l++)
{
g[k][l]=a[xu[i][j]][k][l];
}
}
}
else if(j==)
{
for(int k=;k<n;k++)
{
for(int l=;l<n;l++)
{
g[k][l+n]=a[xu[i][j]][k][l];
}
}
}
else if(j==)
{
for(int k=;k<n;k++)
{
for(int l=;l<n;l++)
{
g[k+n][l]=a[xu[i][j]][k][l];
}
}
}
else if(j==)
{
for(int k=;k<n;k++)
{
for(int l=;l<n;l++)
{
g[k+n][l+n]=a[xu[i][j]][k][l];
}
}
}
}
memset(vis,,sizeof(vis));
sum=;DFS(,,'');
minn=min(minn,sum);
memset(vis,,sizeof(vis));
sum=;DFS(,,'');
minn=min(minn,sum);
}
cout<<minn<<endl;
}

D题 n个点 问是否都在   某一条或某两条直线上

解析  n<3 yes   n>=3 对于任意三个点a,b,c   若a,b在一条直线上L,除去在L的点,如果剩下的的点在一条直线上 有解

             若a,c在一条直线上L,除去在L的点,如果剩下的的点在一条直线上 有解

             若b,c在一条直线上L,除去在L的点,如果剩下的的点在一条直线上 有解

             若三种情况都没有解  则无解

 #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <utility>
using namespace std;
const int maxn = 1e6+,inf = 0x3f3f3f3f,mod = ;
const double epx = 1e-;
const double pi = acos(-1.0);
typedef long long ll;
const ll INF = 1e18;
int n,m,k;
typedef pair<int,int> pii;
pii p[maxn];
int vis[maxn];
pii operator -(const pii &a,const pii &b)
{
return {a.first-b.first,a.second-b.second};
}
ll cross(const pii &a,const pii &b)
{
return a.first*1ll*b.second-a.second*1ll*b.first;
}
bool check()
{
int i1=-,i2=-;
for(int i=;i<n;i++)
{
if(vis[i])
continue;
if(i1==-)
i1=i;
else if(i2==-)
i2=i;
}
if(i2==-)
return true;
for(int i=;i<n;i++)
{
if(vis[i])
continue;
if(cross(p[i2]-p[i1],p[i]-p[i1])!=)
return false;
}
return true;
}
bool check2(pii a,pii b)
{
memset(vis,,sizeof(vis));
for(int i=;i<n;i++)
{
if(cross(b-a,p[i]-a)==)
vis[i]=;
}
return check();
}
int main()
{
cin>>n;
for(int i=;i<n;i++)
cin>>p[i].first>>p[i].second;
if(n<=)
cout<<"YES"<<endl;
else
{
if(check2(p[],p[])||check2(p[],p[])||check2(p[],p[]))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return ;
}

Educational Codeforces Round 41 B、C、D的更多相关文章

  1. Educational Codeforces Round 41 967 E. Tufurama (CDQ分治 求 二维点数)

    Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 ...

  2. Educational Codeforces Round 41

    Educational Codeforces Round 41  D. Pair Of Lines 考虑先把凸包找出来,如果凸包上的点数大于\(4\)显然不存在解,小于等于\(2\)必然存在解 否则枚 ...

  3. Educational Codeforces Round 12 B C题、

    B. Shopping 题意:n个顾客,每个顾客要买m个物品,商场总共有k个物品,看hint就只知道pos(x)怎么算了,对于每一个Aij在k个物品中找到Aij的位置.然后加上这个位置对于的数值,然后 ...

  4. Educational Codeforces Round 10 A B题、

    A. Gabriel and Caterpillar 题意: 就是说  一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方.毛毛虫从10点爬到22点.每小时爬的距离是a, 晚上22点到第二天早上10点 ...

  5. Educational Codeforces Round 41 A B C D E

    A. Tetris 题意 俄罗斯方块,问能得多少分. 思路 即求最小值 Code #include <bits/stdc++.h> #define F(i, a, b) for (int ...

  6. Educational Codeforces Round 41 (Rated for Div. 2)F. k-substrings

    题意比较麻烦略 题解:枚举前缀的中点,二分最远能扩展的地方,lcp来check,然后线段树维护每个点最远被覆盖的地方,然后查询线段树即可 //#pragma GCC optimize(2) //#pr ...

  7. Educational Codeforces Round 41 (Rated for Div. 2)(A~D)

    由于之前打过了这场比赛的E题,而后面两道题太难,所以就手速半个多小时A了前4题. 就当练手速吧,不过今天除了C题数组开小了以外都是1A A Tetris 题意的抽象解释可以在Luogu里看一下(话说现 ...

  8. Educational Codeforces Round 41 (Rated for Div. 2)

    这场没打又亏疯了!!! A - Tetris : 类似俄罗斯方块,模拟一下就好啦. #include<bits/stdc++.h> #define fi first #define se ...

  9. Educational Codeforces Round 41 (Rated for Div. 2) ABCDEF

    最近打的比较少...就只有这么点题解了. A. Tetris time limit per test 1 second memory limit per test 256 megabytes inpu ...

随机推荐

  1. office doc/xls/ppt 和 docx/xlsx/pptx 区别

    经同事告诉,今天才真正明白两都区别: doc/xls/ppt  是office2007以前的扩展名: docx/xlsx/pptx 是office2007版本及以后的扩展名,是基于xml的文件格式,x ...

  2. C#_JDBC连接数据库

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. Shiro 自定义登陆、授权、拦截器

    Shiro 登陆.授权.拦截 按钮权限控制 一.目标 Maven+Spring+shiro 自定义登陆.授权 自定义拦截器 加载数据库资源构建拦截链 使用总结: 1.需要设计的数据库:用户.角色.权限 ...

  4. Android开发——蓝牙

    ---恢复内容开始--- 前言 孤芳自赏,一揽芳华: 人情冷暖,自在人心: 登高远眺,望步止前: 喜笑言开,欺人骗己. 上篇文章介绍了基本的蓝牙使用,书写的demo也不是很完善,希望各位大神能够改正. ...

  5. 掌握Spark机器学习库-07-回归算法原理

    1)机器学习模型理解 统计学习,神经网络 2)预测结果的衡量 代价函数(cost function).损失函数(loss function) 3)线性回归是监督学习

  6. 掌握Spark机器学习库-06-基础统计部分

    说明 本章主要讲解基础统计部分,包括基本统计.假设检验.相关系数等 数据集 数据集有两个文件,分别是: beijing.txt 北京历年降水量,不带年份 beijing2.txt 北京历年降水量,带年 ...

  7. 怎么学好XXX

    怎么学好数据库是一个比较大题目,数据库不仅仅是写SQL那么简单,即使知道了SQL怎么写,还需要很清楚的知道这条SQL他大概扫描了多少数据,返回多少数据,是否需要创建索引.至于SQL优化是一个比较专业的 ...

  8. java实现的单点登录

    摘要:单点登录(SSO)的技术被越来越广泛地运用到各个领域的软件系统当中.本文从业务的角度分析了单点登录的需求和应用领域:从技术本身的角度分析了单点登录技术的内部机制和实现手段,并且给出Web-SSO ...

  9. cocos2dx游戏如何架构

    声明:此篇文章不介绍如何使用cocos2dx制作游戏.站在架构师的角度如果制作游戏. 以我多年的游戏开发经验,和其他技术积累, 市面的所谈的一些软件架构模式都不太适合游戏软件. 我指的架构模式,MVC ...

  10. webservice和一般处理程序

    一丶WebService 1.新建项目 2.选择Web窗体 3.添加新建项 二丶一般处理程序 前台访问: $.ajax({ type: "post", url: "Han ...