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. Android开发学习--ViewPager使用入门

    ViewPager已经有了滑动的功能 activity_main.xml <?xml version="1.0" encoding="utf-8"?> ...

  2. FastDFS的简单使用

    互联网中有海量的文件,比如电商网站有海量的图片文件,视频网站有海量的视频文件,如果使用传统的模式上传文件,肯定是不可取的.因此需要使用第三方服务器来存储图片 . 一.FastDFS简介 ​ FastD ...

  3. 【PostgreSQL-9.6.3】一般视图

    PG视图分为两种,一种是物化视图,一种是一般视图.本篇文章主要写一般视图哪些事儿.所谓一般视图,通俗点说,就是由查询语句定义的虚拟表.视图中的数据可能来自一张或多张表. 1. 视图创建语句 CREAT ...

  4. Farseer.net轻量级开源框架 中级篇:BasePage、BaseController、BaseHandler、BaseMasterPage、BaseControls基类使用

    导航 目   录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: UrlRewriter 地址重写 下一篇:Farseer.net轻量级开源框架 中 ...

  5. 迅为i.MX6Q嵌入式开发板

    工业级核心板:核心板10层高速PCB设计,充分保证电磁兼容. 01. 处理器:开发板默认是四核商业扩展级芯片,可根据用户需求更换单核.双核.工业级.汽车级处理器,批量更省成本. 02. 扩展引脚:32 ...

  6. Codeforces_791_B. Bear and Friendship Condition_(dfs)

    B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes in ...

  7. Android(java)学习笔记201:JNI之helloword案例(利用NDK工具)

    1. 逻辑思路过程图: 2.下面通过一个HelloWorld案例来说明一下JNI利用NDK开发过程(步骤) 分析:我们在Win7系统下编译的C语言代码,我们知道C语言依赖操作系统,不能跨平台,所以我们 ...

  8. nexus 搭建 maven 私服

    nexus 搭建 maven 私服 本机环境 Win 8 JDK 7 Maven 3.2 Nexus 2.11 版本选择 http://www.sonatype.org/nexus/archivedn ...

  9. xshell连接不了虚拟机处理方法(错误提示:Connection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(localhost) at 08:47:23.)

    一.问题描述:xshell连接不了虚拟机,出现错误提示:Connection closing...Socket close.Connection closed by foreign host.Disc ...

  10. 【转】vfork 和 fork的区别

    fork()与vfock()都是创建一个进程,那他们有什么区别呢?总结有以下三点区别: 1.  fork  ():子进程拷贝父进程的数据段,代码段     vfork ( ):子进程与父进程共享数据段 ...