这场没打又亏疯了!!!

A - Tetris :

类似俄罗斯方块,模拟一下就好啦。

 #include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
using namespace std; typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=+;
const int M=; int n, m; int cnt[N];
int main() { int ans = ;
scanf("%d%d", &n, &m);
for(int i = ; i <= m; i++) {
int x; scanf("%d", &x);
cnt[x]++; bool flag = true;
for(int j = ; j <= n; j++) {
if(cnt[j] == )
flag = false;
} if(flag) {
ans++;
for(int j = ; j <= n; j++) {
cnt[j] -= ;
}
}
} printf("%d\n", ans);
return ;
}
/*
*/

B - Lecture Sleep

瞎模拟一下就好啦。

 #include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
using namespace std; typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+;
const int M=; int n, k, a[N], t[N],sum1[N], sum2[N]; int main() { scanf("%d%d", &n, &k); for(int i = ; i <= n; i++) {
scanf("%d", &a[i]);
sum1[i] = sum1[i-] + a[i];
} for(int i = ; i <= n; i++) {
scanf("%d", &t[i]);
sum2[i] = sum2[i-];
if(t[i])
sum2[i] += a[i];
} int ans = sum2[n]; for(int i = ; i + k - <= n; i++) {
ans = max(ans, sum2[n] + (sum1[i+k-] - sum1[i-]) - (sum2[i+k-] - sum2[i-]));
} printf("%d\n",ans);
return ;
}
/*
*/

C - Chessboard

每个块只有两种情况,第一种是第一个数字为0,第二种是第一个数字为1,把每个块这两种情况需要修改的个数记录下来,

然后暴力枚举就好啦 。

 #include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
using namespace std; typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+;
const int M=; int n, a[][], s[][],id[];
int main() { scanf("%d", &n); for(int k = ; k < ; k++) {
for(int i = ; i < n; i++) {
for(int j = ; j < n; j++) {
scanf("%1d", &s[i][j]);
}
} int flag = ;
for(int i = ; i < n; i++) {
for(int j = ; j < n; j++) {
if(flag != s[i][j])
a[k][]++;
flag ^= ;
}
} flag = ;
for(int i = ; i < n; i++) {
for(int j = ; j < n; j++) {
if(flag !=s[i][j])
a[k][]++;
flag ^= ;
}
}
}
for(int i = ; i < ; i++)
id[i] = i; int ans = inf;
do
{
ans = min(ans, a[id[]][] + a[id[]][] + a[id[]][] + a[id[]][]);
}while(next_permutation(id, id + )); for(int i = ; i < ; i++)
id[i] = i; do
{
ans = min(ans, a[id[]][] + a[id[]][] + a[id[]][] + a[id[]][]);
}while(next_permutation(id, id + )); printf("%d\n", ans);
return ;
}
/*
*/

D - Pair Of Lines

题意:给你若干个点,问你能不能最多划两条直线覆盖所有点。

思路:先找到三个不共线的点组成一个三角形,其中一条边一定是需要划的直线,枚举一下这三条边,然后check一下剩下的

点在不在一条直线上。

 #include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
using namespace std; typedef long long LL;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+;
const int M=; struct point {
LL x, y;
}p[N]; LL aross(point a, point b, point c) {
return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
} vector<point> v;
int n;
int main() { scanf("%d", &n); if(n <= ) {
puts("YES");
return ;
}
for(int i = ; i < n; i++) {
scanf("%lld", &p[i].x);
scanf("%lld", &p[i].y);
} int pos = ; while(pos < n && !aross(p[], p[], p[pos]))
pos++; if(pos == n) {
puts("YES");
return ;
} else { for(int i = ; i < n; i++) {
if(aross(p[], p[], p[i]) != )
v.push_back(p[i]);
} if(v.size() <= ) {
puts("YES");
return ;
} bool flag = true; for(int i = ; i < v.size(); i++) {
if(aross(v[], v[], v[i]) !=) {
flag = false;
break;
}
} if(flag) {
puts("YES");
return ;
} v.clear();
for(int i = ; i < n; i++) {
if(aross(p[], p[pos], p[i]) != )
v.push_back(p[i]);
} if(v.size() <= ) {
puts("YES");
return ;
} flag = true; for(int i = ; i < v.size(); i++) {
if(aross(v[], v[], v[i]) !=) {
flag = false;
break;
}
} if(flag) {
puts("YES");
return ;
} v.clear();
for(int i = ; i < n; i++) {
if(aross(p[], p[pos], p[i]) != )
v.push_back(p[i]);
} if(v.size() <= ) {
puts("YES");
return ;
} flag = true; for(int i = ; i < v.size(); i++) {
if(aross(v[], v[], v[i]) !=) {
flag = false;
break;
}
} if(flag) {
puts("YES");
return ;
} puts("NO");
}
return ;
}
/*
*/

E - Tufurama

裸的主席树,没啥好说的,数组开小了两次一次WA,一次RE。。。

 #include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
using namespace std; typedef long long LL;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const int N=4e5+;
const int M=; int root[N],hs[N],a[N],tot;
struct Chairman_tree
{
int cnt;
struct node{
int l,r;
ll sum;
}a[*N];
void update(int l,int r,int &x,int y,int pos,int v)
{
a[++cnt]=a[y];
x=cnt; a[x].sum+=v;
if(l==r) return;
int mid=(l+r)>>;
if(pos<=mid)
update(l,mid,a[x].l,a[y].l,pos,v);
else
update(mid+,r,a[x].r,a[y].r,pos,v);
}
ll query(int l,int r,int L,int R,int x)
{
if(l >= L && r <= R)
return a[x].sum;
ll ans = ;
int mid = (l + r) >> ;
if(L <= mid)
ans += query(l,mid,L,R,a[x].l);
if(R > mid)
ans += query(mid + ,r,L,R,a[x].r);
return ans;
}
}seg; int n;
int main() { scanf("%d", &n); for(int i = ; i <= n; i++) {
scanf("%d", &a[i]);
hs[++tot] = a[i];
hs[++tot] = i;
} sort(hs + , hs + tot + );
tot = unique(hs + , hs + tot + ) - hs - ; for(int i = ; i <= n; i++) {
int pos = lower_bound(hs+,hs++tot,a[i])-hs;
seg.update(,tot,root[i],root[i-],pos,);
} ll ans = ;
for(int i = ; i <= n; i++) {
int item = lower_bound(hs+,hs++tot,i)-hs;
int pos = min(i - , a[i]);
ans += seg.query(, tot, item, tot, root[pos]);
} printf("%lld\n",ans);
return ;
}
/*
*/

Educational Codeforces Round 41 (Rated for Div. 2)的更多相关文章

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

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

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

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

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

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

  4. D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))

    #include <vector> #include <iostream> #include <algorithm> using namespace std; ty ...

  5. C. Chessboard( Educational Codeforces Round 41 (Rated for Div. 2))

    //暴力 #include <iostream> #include <algorithm> #include <string> using namespace st ...

  6. B. Lecture Sleep( Educational Codeforces Round 41 (Rated for Div. 2))

    前缀后缀和搞一搞,然后枚举一下区间,找出最大值 #include <iostream> #include <algorithm> using namespace std; ; ...

  7. 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果点的个数<=3 那么直接输出有解. 否则. 假设1,2最后会在一条直线上,则把这条直线上的点都删掉. 看看剩余的点是否在同 ...

  8. Educational Codeforces Round 41 (Rated for Div. 2) D. Pair Of Lines (几何,随机)

    D. Pair Of Lines time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

随机推荐

  1. 洛谷 P2178 [NOI2015]品酒大会 解题报告

    P2178 [NOI2015]品酒大会 题目描述 一年一度的"幻影阁夏日品酒大会"隆重开幕了.大会包含品尝和趣味挑战 两个环节,分别向优胜者颁发"首席品酒家"和 ...

  2. 【poj3415】 Common Substrings

    http://poj.org/problem?id=3415 (题目链接) 题意 给定两个字符串 A 和 B,求长度不小于 k 的公共子串的个数(可以相同). Solution 后缀数组论文题... ...

  3. HDU 1611 敌兵布阵 / HRBUST 1794 敌兵布阵(线段树)

    HDU 1611 敌兵布阵 / HRBUST 1794 敌兵布阵(线段树) Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A ...

  4. (转)java中使用memcache

    背景:公司项目中使用java和memcache相结合来搭建缓存,所以要了解下缓存的基础知识! 1 了解memcache 1.1 基础知识 什么是Memcache? Memcache集群环境下缓存解决方 ...

  5. RPC与RMI的区别

    分布式项目按照以下发展经历了以下技术: CORBA: RMI:基于远程接口的调用 RMI-RROP:这是RMI与CORBA的结合,用在了EJB技术上,EJB留给世界上是优秀的理论和糟糕的架构. WEB ...

  6. std::bind常见的坑

    http://note.youdao.com/noteshare?id=bce9cdea8e94501186b5ba3026af685f

  7. Centos7搭建SS以及加速配置的操作记录

    部署 Shadowsocks之前,对它做了一个简单的了解,下面先介绍下.一道隐形的墙众所周知,天朝局域网通过 GFW (中国防火墙长城:英文名称Great Firewall of China,简写为G ...

  8. centos7+mysql5.7.11实现主从复制

    1  首先检测当前的系统是否已经安装了MySQL yum list installed | grep mysql 如果有的话,删除 2  下载rpm库资源,在网页 https://dev.mysql. ...

  9. python oracle使用心得

    Oracel安装(windows 64位) 1. 首先确定版本. 2. 下载instantclient,下载地址:http://www.oracle.com/technetwork/database/ ...

  10. 用到的设计模式总结--单例模式+工厂方法模式+Builder模式

    一,工厂方法模式和单例模式 工厂方法模式中有一个抽象的工厂接口和一个抽象的产品接口.然后,具体的工厂实现抽象工厂并负责生产具体的产品.由客户端决定 new 哪个具体的工厂,从而生产哪种产品. 因此,与 ...