前一半是刚刚打完比赛的时候写的……不知为啥手腕有点僵,估计是前一个小时用力过度了吧= =

前四题看着还好,后两题就有点懵逼了……现在还不知道E题的题意到底是啥……

不管了……还没找着官方题解,贴一下自己的做法算了……

A显然是傻逼题啊……没注意到a,b都是0的情况,被hack了一次……

 #include<cstdio>
using namespace std;
int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a==&&b==)printf("NO");
else{
if(a>b){
int t=a;
a=b;
b=t;
}
printf(b-a<=?"YES":"NO");
}
return ;
}

B也是傻逼题,暴力判断就行……

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool judge();
int n,m,a[],b[];
int main(){
bool ok=false;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)scanf("%d",&a[i]);
for(int i=;i<=n;i++)scanf("%d",&b[i]);
for(int i=;i<n;i++){
if(judge()){
ok=true;
break;
}
rotate(a+,a+,a+n+);
}
printf(ok?"YES":"NO");
return ;
}
bool judge(){
int tmp=(a[]-b[]+m)%m;
for(int i=;i<=n;i++)if((a[i]-b[i]+m)%m!=tmp)return false;
return true;
}

C也是傻逼题,枚举三种符号出现在哪三行,其余的行就不用动了。

为了防止花式TLE我写了预处理代价……

 #include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
const int maxn=;
char s[maxn];
int n,m,f[maxn][],ans=0x3f3f3f3f;
int main(){
scanf("%d%d",&n,&m);
memset(f,,sizeof(f));
for(int i=;i<n;i++){
scanf("%s",s);
for(int j=;j<m;j++){
if(isdigit(s[j]))f[i][]=min(f[i][],min(j,m-j));
else if(islower(s[j]))f[i][]=min(f[i][],min(j,m-j));
else if(s[j]=='#'||s[j]=='*'||s[j]=='&')f[i][]=min(f[i][],min(j,m-j));
}
}
for(int i=;i<n;i++)for(int j=;j<n;j++)if(i!=j)for(int k=;k<n;k++)if(i!=k&&j!=k)ans=min(ans,f[i][]+f[j][]+f[k][]);
printf("%d",ans);
return ;
}

D也不难吧……看了看觉得就是按排名贪心,sort一下就好了……

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=;
struct A{
int x,pos;
bool operator<(const A &a)const{return x<a.x;}
}c[maxn];
int n,a[maxn],b[maxn],l,r,last=-1e9+;
int main(){
scanf("%d%d%d",&n,&l,&r);
for(int i=;i<=n;i++)scanf("%d",&a[i]);
for(int i=;i<=n;i++){
scanf("%d",&c[i].x);
c[i].pos=i;
}
sort(c+,c+n+);
bool ok=true;
for(int i=;i<=n;i++){
b[c[i].pos]=max(l,last+a[c[i].pos]+);
last=b[c[i].pos]-a[c[i].pos];
if(b[c[i].pos]>r){
ok=false;
break;
}
}
if(ok)for(int i=;i<=n;i++){
if(i>)printf(" ");
printf("%d",b[i]);
}
else printf("-1");
return ;
}

E听说主要考读题……药丸啊药丸

我理解的题意是说所有边长度为1,边之间只能成直角或平角,问树是否可以画在平面上……

反正n的范围这么小,找个重心之后求个bfs序,按bfs序暴搜……反正我过了Pretest,跑的还挺快……

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int maxn=,dx[]={,,-,},dy[]={-,,,};
void getcenter(int);
void dfs(int);
vector<int>G[maxn];
bool vis[maxn][maxn]={false};
int size[maxn]={},son[maxn]={},id[maxn],tim=;
int n,center=,x,y,du[maxn]={},a[maxn],b[maxn],p[maxn];
bool ok=false;
int main(){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&x,&y);
G[x].push_back(y);
G[y].push_back(x);
du[x]++;
du[y]++;
}
bool bad=false;
for(int i=;i<=n;i++)if(du[i]>){
bad=true;
break;
}
if(bad){
printf("NO");
return ;
}
getcenter();
x=center;
getcenter(center);
a[x]=b[x]=;
vis[][]=true;
dfs();
if(ok){
printf("YES\n");
for(int i=;i<=n;i++)printf("%d %d\n",a[i],b[i]);
}
else printf("NO");
return ;
}
void getcenter(int x){
queue<int>q;
int tim=;
fill(p,p+n+,);
q.push(x);
while(!q.empty()){
x=q.front();
q.pop();
id[++tim]=x;
size[x]=;
for(int i=;i<(int)G[x].size();i++)if(G[x][i]!=p[x]){
p[G[x][i]]=x;
q.push(G[x][i]);
}
}
for(int i=n;i;i--){
x=id[i];
size[p[x]]+=size[x];
if(size[x]>size[son[p[x]]])son[p[x]]=x;
}
for(int i=;i<=n;i++){
x=id[i];
if(!center||max(n-size[x],size[son[x]])<max(n-size[center],size[son[center]]))center=x;
}
}
void dfs(int k){
if(k==n+){
ok=true;
return;
}
register int x=id[k];
for(int i=;i<;i++)if(!vis[a[p[x]]+dx[i]+][b[p[x]]+dy[i]+]){
a[x]=a[p[x]]+dx[i];
b[x]=b[p[x]]+dy[i];
vis[a[x]+][b[x]+]=true;
dfs(k+);
if(ok)return;
vis[a[x]+][b[x]+]=false;
}
}

UPD:理解错了题意了…… 然后就WA了,英死早……

话说这次的比赛不太资瓷啊……room老是炸,中间好不容易能看了,lock了C之后看别人的代码,看着看着突然发现有个傻小伙把m-j写成了n-j+1,火速造了个小数据,交上去之后也不知到底hack上了没有……

本来做出来了四道水题,然后因为CF的系统不太资瓷结果unrated了……不好玩……

Codeforces Round #394 (Div. 2)的更多相关文章

  1. Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)

    E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #394 (Div. 2) 颓废记

    昨天晚上(今天凌晨),又忍不住去打CF.(本蒟弱到只能打Div.2)... 我觉得我可以用一个词概括我这次的CF: 呵呵 刚一开赛,我就codeforces访问失败.. 后来好不容易能上了,两三分钟才 ...

  3. Codeforces Round #394 (Div. 2) E. Dasha and Puzzle 构造

    E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to h ...

  4. Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem 贪心

    D. Dasha and Very Difficult Problem 题目连接: http://codeforces.com/contest/761/problem/D Description Da ...

  5. Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力

    C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming ...

  6. Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力

    B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...

  7. Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题

    A. Dasha and Stairs 题目连接: http://codeforces.com/contest/761/problem/A Description On her way to prog ...

  8. Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(dfs)

    http://codeforces.com/contest/761/problem/E 题意:给出一棵树,现在要把这棵树上的结点放置在笛卡尔坐标上,使得每一条边与x轴平行或者与y轴平行.输出可行解,即 ...

  9. Codeforces Round #394 (Div. 2) C.Dasha and Password(暴力)

    http://codeforces.com/contest/761/problem/C 题意:给出n个串,每个串的初始光标都位于0(列)处,怎样移动光标能够在凑出密码(每个串的光标位置表示一个密码的字 ...

  10. Codeforces Round #394 (Div. 2) B. Dasha and friends(暴力)

    http://codeforces.com/contest/761/problem/B 题意: 有一个长度为l的环形跑道,跑道上有n个障碍,现在有2个人,给出他们每过多少米碰到障碍,判断他们跑的是不是 ...

随机推荐

  1. css块元素及内联元素

    块级元素主要有: address , blockquote , center , dir , div , dl , fieldset , form , h1 , h2 , h3 , h4 , h5 , ...

  2. Python的__getattribute__二三事

    本来以为自己对__getattribute__已经比较了解了,结果用到的时候,才发现有一些知识点之前一直没有真正弄明白,记录如下(针对python3,python2差异较大): object类有__g ...

  3. Springboot第一篇:框架了解与搭建

    在上一章,我讲解了React+node+express相应的框架搭建,一个项目只有一个前端框架够么,当然不够啦!!! 所以这节我们就来讲后台springboot框架的搭建和相关原理吧~~~版本(2.1 ...

  4. python之类与对象(2)

    3. 类函数的进阶 3.1 类函数调用类属性 关于类函数调用类属性,我们尝试修改前一节的内容,以我们在之前学习的内容,调用属性直接用%+属性就可以了,那我们来试一下: 看到了程序有报错,这其实是因为在 ...

  5. BZOJ - 3263 三维偏序

    题意:定义元素为有序组(a,b,c),若存在x组(a_i,b_i,c_i)分别小于等于(a,b,c),则该元素的等级为x,求[0,n-1]等级的个数 cdq分治练手题,对a简单排序并去重,对b进行分治 ...

  6. 解决NTFS文件系统下的文件/文件夹属性中没有安全选项卡的问题

    注册表项: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer 键:NoSecurityTab ...

  7. rsa字符串格式公钥转换python rsa库可识别的公钥形式

    在爬虫分析的时候,经常在网页上看到如下格式的rsa公钥: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC7kw8r6tq43pwApYvkJ5laljaN9BZb21 ...

  8. C#只启动一个进程的代码

    把写内容过程中经常用到的内容做个收藏,如下的内容是关于C#只启动一个进程的内容.public partial class App : Application { protected override ...

  9. C# 修改系统时间

    /// <summary> /// 同步服务时间 /// </summary> public class SyncServerTime { //设置系统时间的API函数 [Dl ...

  10. Ubuntu安装google-chrome

    原文地址:http://www.linuxidc.com/Linux/2013-10/91857.htm安装谷歌浏览器,只需要三行代码: 打开终端,输入 cd /tmp 对于谷歌Chrome32位版本 ...