Codeforces Round #524 Div. 2 翻车记
A:签到。room里有一个用for写的,hack了一发1e8 1,结果用了大概600+ms跑过去了。惨绝人寰。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,m;
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif*/
n=read(),m=read();
cout<<(n*-)/m++(n*-)/m++(n*-)/m+;
return ;
}
B:讨论一发即可。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 1010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n;
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif*/
n=read();
while (n--)
{
int x=read(),y=read();
int p=y;if (y-x+&) y--;
int ans=x&?(y-x+>>):-(y-x+>>);
if (p-x+&) ans+=p&?-p:p;
printf("%d\n",ans);
}
return ;
}
C:对矩形求个交,冷静一下瞎算算就行了。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 1010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int T,n,m;
ll area(int x1,int y1,int x2,int y2){if (x1>x2||y1>y2) return ;return 1ll*(x2-x1+)*(y2-y1+);}
ll calcwhite(int x1,int y1,int x2,int y2)
{
ll s=area(x1,y1,x2,y2);
if (x1+y1&) return s>>;
else return s+>>;
}
ll calcblack(int x1,int y1,int x2,int y2){return area(x1,y1,x2,y2)-calcwhite(x1,y1,x2,y2);}
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif*/
T=read();
while (T--)
{
n=read(),m=read();
int x1=read(),y1=read(),x2=read(),y2=read();
int x3=read(),y3=read(),x4=read(),y4=read();
int x5=max(x1,x3),y5=max(y1,y3),x6=min(x2,x4),y6=min(y2,y4);
ll white=calcwhite(,,n,m),black=calcblack(,,n,m);
ll c1=calcblack(x1,y1,x2,y2);white+=c1,black-=c1;
black+=calcwhite(x3,y3,x4,y4),white-=calcwhite(x3,y3,x4,y4);
if (area(x5,y5,x6,y6)) black+=calcblack(x5,y5,x6,y6),white-=calcblack(x5,y5,x6,y6);
printf("%I64d %I64d\n",white,black);
}
return ;
}
D:考虑答案为i时的最小和最大分裂次数是多少,各种递推式求通项到最后能捣鼓出来两个式子。显然答案若存在与n相差不会很大,暴力枚举check即可。当然式子不能直接算,需要各种乱搞防溢出。数学太差推一年。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll unsigned long long
#define N 1010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
ll read()
{
ll x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int T,n,m;
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif*/
T=read();
while (T--)
{
ll n=read(),m=read();
int ans=-;
for (int i=(n>=?n-:);i<n;i++)
{
ll k=;
for (int j=;j<=n-i+;j++) k<<=;
k-=n-i;k-=;
if (k<=m)
{
if (n+i+>=) {ans=i;break;}
ll k=;for (int j=;j<=n-i-;j++) k<<=;k--;ll t=k+;
for (int j=;j<=n+i+;j++)
{
k<<=;
if (k>=*m+) {ans=i;break;}
}
if (ans!=-) break;
t<<=;if (t>=*m+) {ans=i;break;}
t<<=;if (t>=*m+) {ans=i;break;}
k+=t;if (k>=*m+) {ans=i;break;}
t=;
for (int j=;j<=*i;j++)
{
t<<=;
if (t>=*m+) {ans=i;break;}
}
if (ans!=-) break;
k+=t;if (k>=*m+) {ans=i;break;}
}
}
if (ans==-) printf("NO\n");
else printf("YES %d\n",ans);
}
return ;
}
E:这个条件比较显然的等价于子矩形中每一行都能重排成回文串(即出现次数为奇数的字母不超过一个)且对称行的字母组成相同。预处理每一行的每一段是否合法以及字母出现次数的哈希值,暴力枚举子矩形左右端点,对上下端点的每段合法区间马拉车即可。完全没时间写了。
F:没看
小号打的。result:rank 139 rating +92
Codeforces Round #524 Div. 2 翻车记的更多相关文章
- Codeforces Round#500 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Codeforces Round#509 Div.2翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Educational Codeforces Round 56 Div. 2 翻车记
A:签到. B:仅当只有一种字符时无法构成非回文串. #include<iostream> #include<cstdio> #include<cmath> #in ...
- Educational Codeforces Round 55 Div. 2 翻车记
A:签到. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> ...
- Codeforces Round#514 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Codeforces Round#516 Div.1 翻车记
A:开场懵逼.然后发现有人1min过,于是就sort了一下,于是就过了.正经证明的话,考虑回文串两端点一定是相同的,所以最多有Σcnti*(cnti+1)/2个,cnti为第i种字母出现次数.而sor ...
- Codeforces Round #517 Div. 1翻车记
A:真的懵逼了.冷静了半天之后决定二分一下答案,然后先a安排上尽量小的再贪心地一个个扩大.40min才过.这个做法非常怂的以代码复杂度和时间复杂度为代价换取了比较稳的正确性,事实上由于1~n可以组合出 ...
- Educational Codeforces Round 53 Div. 2翻车记
A:差点开场懵逼.只要有相邻两位不同就可以作为答案. #include<iostream> #include<cstdio> #include<cmath> #in ...
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
随机推荐
- Linux getcwd()的实现
通过getcwd()可以获取当前工作目录. #include <unistd.h> char *getcwd(char *cwdbuf, size_t size); 成功调用返回指向cwd ...
- java生成PDF,并下载到本地
1.首先要写一个PDF工具类,以及相关工具 2.PDF所需jar包 iText是一种生成PDF报表的Java组件 freemarker是基于模板来生成文本输出 <dependency> & ...
- spark中数据倾斜解决方案
数据倾斜导致的致命后果: 1 数据倾斜直接会导致一种情况:OOM. 2 运行速度慢,特别慢,非常慢,极端的慢,不可接受的慢. 搞定数据倾斜需要: 1.搞定shuffle 2.搞定业务场景 3 搞定 c ...
- 三、并行流与串行流 Fork/Join框架
一.并行流概念: 并行流就是把一个内容分成多个数据块,并用不同的线程分别处理每个数据块的流. java8中将并行进行了优化,我们可以很容易的对数据进行并行操作.Stream API可以声明性的通过pa ...
- “地表最贵iPhone”到货,iPhone XS 系列手机等你来测!
WeTest 导读 9月13日,苹果正式发布了全新的 iPhone XS 系列智能手机,备受瞩目的iPhone家族新成员具体又是怎样的呢? 关于iPhone XS系列手机的那些新亮点 大屏.双 ...
- UnityShader - 模拟动态光照特效
模型贴片 + 特效Shader = 动态光照特效 效果是这样的: 做法简单粗暴,直接使用模型贴片: shader上使用了noise只是提供一种思路,也有更简单的方法代替
- Python全栈 正则表达式(re模块正则接口全方位详解)
re模块是Python的标准库模块 模块正则接口的整体模式 re.compile 返回regetx对象 finditer fullmatch match search 返回 match对象 match ...
- lintcode101 删除排序数组中的重复数字 II
删除排序数组中的重复数字 II 跟进“删除重复数字”: 如果可以允许出现两次重复将如何处理? 在:lintcode100删除排序数组中的重复数字 的基础上进行改进. class Solution ...
- Java中二进制数与整型之间的转换
import java.io.*; public class Test{ /** * 二进制与整型之间的转换 * @param args * @throws IOException */ public ...
- solidity 智能合约操作
合约编译 #!/usr/bin/env python # coding: utf8 import json import os # Solc Compiler from functools impor ...