再次作死的打了一次cf的修仙比赛感觉有点迷。。

还好掉的分不多(原本就太低没法掉了QAQ)

把会做的前三道水题记录在这。。

A: Antipalindrome

emmmm...直接暴力枚举

code:

//By Menteur_Hxy
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; int n,ans;
char ch[100]; bool jud(int l,int len) {
int r=l+len-1;
for(int i=0;i<(len>>1);i++)
if(ch[l+i]!=ch[r-i]) return 1;
return 0;
} bool check(int len) {
for(int i=1;i+len-1<=n;i++)
if(jud(i,len)) return 1;
return 0;
} int main() {
scanf("%s",ch+1);
n=strlen(ch+1);
for(int i=n;i>1;i--) {
if(check(i)) {ans=i;break;}
}
if(!ans) printf("0");
else printf("%d",ans);
return 0;
}

B: Businessmen Problems

用map直接上记下每个元素的最大值最后加起来

code:

//By Menteur_Hxy
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#define M(a,b) memset(a,(b),sizeof(a))
#define F(i,a,b) for(register int i=(a);i<=(b);i++)
#define LL long long
using namespace std; LL rd() {
LL x=0,fla=1; char c=' ';
while(c<'0'||c>'9') {c=getchar();if(c=='-') fla=-fla;}
while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x*fla;
} map <int,int> M; int main() {
int n=rd();
F(i,1,n) {
int x=rd(),y=rd();
M[x]=y;
}
int m=rd();
F(i,1,m) {
int x=rd(),y=rd();
if(M.count(x)) {
M[x]=max(M[x],y);
}else {
M[x]=y;
}
}
LL ans=0;
for(map<int,int>::iterator it=M.begin();
it!=M.end();it++) {
if(it->second) ans+=it->second;
}
printf("%lld",ans);
return 0;
}

C: Useful Decomposition

题面略迷。。

大概意思是找到一种方式 分配他所给你的一些边 使组成一些简单路径要求每两条简单路径都有一个公共点

保证给出的边组成一棵树,输出路径数和每条路径的起点和终点 (顺序无所谓)这么水的题 题面就让我看了半天QAQ

显然考虑只有一个公共点,记录每个点连着几条边然后分情况:

1.如果有两个点连着超过两条边说明无法完成

2.如果仅有一个点连边超过两条 答案为以它为端点的所有简单路径

3.如果无连边超过两条的那么只有一条简单路径 且两个只连一条边的点为两端点

code: (略暴力)

//By Menteur_Hxy
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#define M(a,b) memset(a,(b),sizeof(a))
#define F(i,a,b) for(register int i=(a);i<=(b);i++)
#define LL long long
using namespace std; inline LL rd() {
LL x=0,fla=1; char c=' ';
while(c>'9'|| c<'0') {if(c=='-') fla=-fla; c=getchar();}
while(c<='9' && c>='0') x=x*10+c-'0',c=getchar();
return x*fla;
} inline void out(LL x){
int a[25],wei=0;
if(x<0) putchar('-'),x=-x;
for(;x;x/=10) a[++wei]=x%10;
if(wei==0){ puts("0"); return;}
for(int j=wei;j>=1;--j) putchar('0'+a[j]);
putchar('\n');
} const int N=10010;
const int INF=0x3f3f3f3f;
int n,rt,cnt;
int du[N],head[N]; struct edges{
int to,next;
}e[N<<2]; void add(int x,int y) {
e[++cnt].next=head[x];
e[cnt].to=y;
head[x]=cnt;
} int dfs(int x,int pre) {
for(int i=head[x];i;i=e[i].next) {
int v=e[i].to;
if(v!=pre) return dfs(v,x);
}
return x;
} int main() {
n=rd();
F(i,1,n-1) {
int u=rd(),v=rd();
add(u,v);add(v,u);
du[u]++,du[v]++;
}
F(i,1,n) if(du[i]>2) rt=i;
F(i,1,n) if(du[i]>2&&i!=rt) {
printf("No");
return 0;
}
if(!rt) {
printf("Yes\n1\n");
F(i,1,n) if(du[i]==1) printf("%d ",i);
return 0;
}
printf("Yes\n%d\n",du[rt]);
for(int i=head[rt];i;i=e[i].next) {
int v=e[i].to;
printf("%d %d\n",rt,dfs(v,rt));
}
return 0;
}

后面回头再说吧(不会做QAQ)



版权声明:本文为博主原创文章,未经博主允许不得转载。https://www.cnblogs.com/Menteur-Hxy/p/9099644.html

cf掉分记——Avito Code Challenge 2018的更多相关文章

  1. Codeforces Avito Code Challenge 2018 D. Bookshelves

    Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...

  2. Avito Code Challenge 2018

    第一次打CF,很菜,A了三道水题,第四题好像是是数位DP,直接放弃了.rateing从初始的1500变成了1499,还是绿名,这就很尴尬.之后觉得后面的题目也没有想象的那么难(看通过人数)过两天吧剩下 ...

  3. Codeforces - Avito Code Challenge 2018

    Portal A. Antipalindrome 暴力. B. Businessmen Problems 暴力. C. Useful Decomposition 居然不是C打头的?! 将一棵树划分成若 ...

  4. Avito Code Challenge 2018 A~E

    A. Antipalindrome 还以为是什么神dp结果就是分情况讨论啊 原串是一串一样的字符的话输出0,是回文串的话输出n-1,否则直接输出原串长度 #include<iostream> ...

  5. Avito Code Challenge 2018 C

    C. Useful Decomposition time limit per test 1 second memory limit per test 256 megabytes input stand ...

  6. [Avito Code Challenge 2018 G] Magic multisets(线段树)

    题目链接:http://codeforces.com/contest/981/problem/G 题目大意: 有n个初始为空的‘魔法’可重集,向一个‘可重集’加入元素时,若该元素未出现过,则将其加入: ...

  7. Codeforces940掉分记

    掉分经过 难得这次时间比较好,下午17:35开始. 本来还很高兴,心想这回肯定不会犯困,没准排名能再上升一些呢,,可惜事与愿违-- 上来a题,光看懂题就花了一些时间. 然后开始写,结果第一遍CE,第二 ...

  8. Avito Cool Challenge 2018 自闭记

    A:n==2?2:1. #include<iostream> #include<cstdio> #include<cmath> #include<cstdli ...

  9. CF480Div2掉分记

    rating 1900+参加只有Div2的比赛也记rating了.还以为yyc报名没打会惨惨,原来不交题好像就不算参加.. 本来太晚了不想打,不过有Sinogi大佬带我还是打一打吧,apio之前练练手 ...

随机推荐

  1. 使用shell脚本定时备份web网站代码

    #!/bin/bash ############### common file ################ #备份文件存放目录 WEBBACK_DIR="/data/backup/ba ...

  2. 10行Python代码实现人脸定位

    10行python机器学习全卷机网,实现100+张人脸同时定位! 发表评论 1,049 游览 A+ 所属分类:未分类 收  藏 今天介绍一个快速定位人脸的深度学习算法MTCNN,全称是:Multi-t ...

  3. Oracle查看哪些表被锁住了

    --查看哪些表被锁住了select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_object ...

  4. OA项目知识总结

    struts文件配置 --------------------------------------------------------- 配置c3po链接池 --------------------- ...

  5. POJ 3709

    简单的单调队列优化,注意是哪些点加入队列即可. #include <iostream> #include <cstdio> #include <algorithm> ...

  6. java 抽象类和接口的差别

     语法层面上: 1)抽象类能够提供成员方法的实现细节.而接口中仅仅能存在public abstract 方法. 2)抽象类中的成员变量能够是各种类型的.而接口中的成员变量仅仅能是public st ...

  7. 用 C 语言编写一个简单的垃圾回收器

    人们似乎觉得编写垃圾回收机制是非常难的,是一种仅仅有少数智者和Hans Boehm(et al)才干理解的高深魔法.我觉得编写垃圾回收最难的地方就是内存分配,这和阅读K&R所写的malloc例 ...

  8. iOS项目开发实战——制作视图的缩放动画

    视图的大小应该是随时可控的.今天我们就来实现对一个View的缩放动画.该动画的实现与位移动画,透明度动画稍有不同. 详细实现例如以下: import UIKit class ScaleViewCont ...

  9. 13.QT多窗口切换list

    Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); list = ...

  10. MSSQL执行大脚本文件时,提示“内存不足”的解决办法

    导出了一个脚本文件,将近900M,回来往sql studio一丢,报了个内存不足,然后就有了此文.. 问题描述: 当客户服务器不允许直接备份时,往往通过导出数据库脚本的方式来部署-还原数据库, 但是当 ...