Educational Codeforces Round 41 (Rated for Div. 2)
这场没打又亏疯了!!!
类似俄罗斯方块,模拟一下就好啦。
#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 ;
}
/*
*/
瞎模拟一下就好啦。
#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 ;
}
/*
*/
每个块只有两种情况,第一种是第一个数字为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 ;
}
/*
*/
题意:给你若干个点,问你能不能最多划两条直线覆盖所有点。
思路:先找到三个不共线的点组成一个三角形,其中一条边一定是需要划的直线,枚举一下这三条边,然后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 ;
}
/*
*/
裸的主席树,没啥好说的,数组开小了两次一次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)的更多相关文章
- Educational Codeforces Round 41 (Rated for Div. 2)F. k-substrings
题意比较麻烦略 题解:枚举前缀的中点,二分最远能扩展的地方,lcp来check,然后线段树维护每个点最远被覆盖的地方,然后查询线段树即可 //#pragma GCC optimize(2) //#pr ...
- Educational Codeforces Round 41 (Rated for Div. 2)(A~D)
由于之前打过了这场比赛的E题,而后面两道题太难,所以就手速半个多小时A了前4题. 就当练手速吧,不过今天除了C题数组开小了以外都是1A A Tetris 题意的抽象解释可以在Luogu里看一下(话说现 ...
- Educational Codeforces Round 41 (Rated for Div. 2) ABCDEF
最近打的比较少...就只有这么点题解了. A. Tetris time limit per test 1 second memory limit per test 256 megabytes inpu ...
- D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))
#include <vector> #include <iostream> #include <algorithm> using namespace std; ty ...
- C. Chessboard( Educational Codeforces Round 41 (Rated for Div. 2))
//暴力 #include <iostream> #include <algorithm> #include <string> using namespace st ...
- B. Lecture Sleep( Educational Codeforces Round 41 (Rated for Div. 2))
前缀后缀和搞一搞,然后枚举一下区间,找出最大值 #include <iostream> #include <algorithm> using namespace std; ; ...
- 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果点的个数<=3 那么直接输出有解. 否则. 假设1,2最后会在一条直线上,则把这条直线上的点都删掉. 看看剩余的点是否在同 ...
- 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 ...
- 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 ...
随机推荐
- 用JS制作博客页面背景随滚动渐变的效果
今天颓了一会,用JavaScript给我的博客园博客写了一个页面背景随滚动而渐变的效果,做完之后自我感觉良好-- 下面就以我的博客园博客为例,介绍一下如何制作这个效果! 准备 [x] 申请博客园的JS ...
- 洛谷 P2047 [NOI2007]社交网络 解题报告
P2047 [NOI2007]社交网络 题目描述 在社交网络(\(social\) \(network\))的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题.在一个社交圈子里有\ ...
- Mysql(三)约束
一.视图 视图是虚拟的数据表,本身不存储数据,而是提供数据的逻辑 展示. 1.创建视图 create view stu_view as select s1.id, s1.name, s2. ...
- P3861 8月月赛A
https://www.luogu.org/problemnew/show/P3861 排序:乘数保持单调递增 dp+hash(map解决) #include <cstdio> #incl ...
- dwr网上使用例子
转: dwr实现聊天室功能 2016年01月15日 10:22:43 我爱喝可乐 阅读数:564 用dwr的comet(推)来实现简单的无刷新多人聊天室,comet是长连接的一种.通常我们要实现无 ...
- k8s如何管理Pod(rc、rs、deployment)
是豆荚,可以把容器想像成豆荚里的豆子,把一个或多个关系紧密的豆子包在一起就是豆荚(一个Pod).在k8s中我们不会直接操作容器,而是把容器包装成Pod再进行管理(关于Pod,大家可以参考第十期的分享“ ...
- Java基础-Java中的并法库之重入读写锁(ReentrantReadWriteLock)
Java基础-Java中的并法库之重入读写锁(ReentrantReadWriteLock) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在学习Java的之前,你可能已经听说过读 ...
- Hadoop生态圈-Flume的组件之sink处理器
Hadoop生态圈-Flume的组件之sink处理器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一. 二.
- 何凯文每日一句打卡||DAY5
- 流媒体技术学习笔记之(十一)Windows环境运行EasyDarwin
流媒体平台框架下载安装 Github下载 下载地址:https://github.com/EasyDarwin/EasyDarwin/releases 解压安装 选择Windows 安装平台的安装包( ...