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. poj2718 Smallest Difference

    思路: 暴力乱搞. 实现: #include <iostream> #include <cstdio> #include <sstream> #include &l ...

  2. SOA测试之浏览器插件

    1. Chrome HTTP Rest Client 插件: 1.1 Postman: https://chrome.google.com/webstore/detail/postman-rest-c ...

  3. iis 配置文件解决跨域问题

    <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Contro ...

  4. Android(java)学习笔记199:JNI之JNI概念

    1. JNI是什么? java native interface (java本机接口) 比如方法声明: public final native Class<?>  getClass(): ...

  5. Python3.0 调用HTMLTestRunner生成的报告中不能显示用例中print函数的输出

    官方原生的HTMLTestRunner.py支持python2.0版本,python3.0版本的使用需要做一些修改: Python3调用HTMLTestRunner执行用例生成测试报告中,不能正常显示 ...

  6. c语言 c++ 实现查看本地ip,外网ip, 本地主机名,查看http网址对应的ip

    /******************************************************************************* 作者 :邓中强 Email :1246 ...

  7. python day one

    今日内容: python基础: 一 编程语言 什么是编程语言? 上面提及的能够被计算机所识别的表达方式即编程语言,语言是沟通的介质,而编程语言是程序员与计算机沟通的介质.在编程的世界里,计算机更像是人 ...

  8. CAD使用SetxDataLong写数据(com接口)

    主要用到函数说明: MxDrawEntity::SetxDataLong 写一个long扩展数据,详细说明如下: 参数 说明 [in] BSTR val 字符串值 szAppName 扩展数据名称 n ...

  9. MySQL系列(一)--数据类型

    如何选择优化的数据类型: 1.通常更小的更好 相同级别的数据类型,选择占据空间更小的数据类型.更小的数据类型通常更快,因为占用更少的磁盘.内存和CPU缓存,处理时需要的 CPU周期也更少,但是要确保需 ...

  10. 进程的互斥运行:CreateMutex函数实现只运行一个程序实例

    HANDLE hMutex=CreateMutex(NULL,TRUE,"HDZBUkeyDoctorTool"); if(hMutex) { if(ERROR_ALREADY_E ...