昨晚因为有点事就去忙了,没打后悔啊

A - XXFESTIVAL


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

Rng is going to a festival.

The name of the festival is given to you as a string S, which ends with FESTIVAL, from input. Answer the question: "Rng is going to a festival of what?" Output the answer.

Here, assume that the name of "a festival of s" is a string obtained by appending FESTIVAL to the end of s. For example, CODEFESTIVAL is a festival of CODE.

Constraints

  • 9≤|S|≤50
  • S consists of uppercase English letters.
  • S ends with FESTIVAL.

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer to the question: "Rng is going to a festival of what?"


Sample Input 1

Copy
CODEFESTIVAL

Sample Output 1

Copy
CODE

This is the same as the example in the statement.


Sample Input 2

Copy
CODEFESTIVALFESTIVAL

Sample Output 2

Copy
CODEFESTIVAL

This string is obtained by appending FESTIVAL to the end of CODEFESTIVAL, so it is a festival of CODEFESTIVAL.


Sample Input 3

Copy
YAKINIKUFESTIVAL

Sample Output 3

Copy
YAKINIKU

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int l=s.length()-;
for(int i=; i<l; ++i)
putchar(s[i]);
return ;
}

B - Problem Set


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

Rng is preparing a problem set for a qualification round of CODEFESTIVAL.

He has N candidates of problems. The difficulty of the i-th candidate is Di.

There must be M problems in the problem set, and the difficulty of the i-th problem must be Ti. Here, one candidate of a problem cannot be used as multiple problems.

Determine whether Rng can complete the problem set without creating new candidates of problems.

Constraints

  • 1≤N≤200,000
  • 1≤Di≤109
  • 1≤M≤200,000
  • 1≤Ti≤109
  • All numbers in the input are integers.

Partial Score

  • 100 points will be awarded for passing the test set satisfying N≤100 and M≤100.

Input

Input is given from Standard Input in the following format:

N
D1 D2 DN
M
T1 T2 TM

Output

Print YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.


Sample Input 1

Copy
5
3 1 4 1 5
3
5 4 3

Sample Output 1

Copy
YES

Sample Input 2

Copy
7
100 200 500 700 1200 1600 2000
6
100 200 500 700 1600 1600

Sample Output 2

Copy
NO

Not enough 1600s.


Sample Input 3

Copy
1
800
5
100 100 100 100 100

Sample Output 3

Copy
NO

Sample Input 4

Copy
15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5

Sample Output 4

Copy
YES

用map看一下数据是否合法就行了

#include<bits/stdc++.h>
using namespace std;
map<int,int>M;
int main()
{
int n,m;
cin>>n;
for(int i=; i<n; i++)
{
int x;
cin>>x,M[x]++;
}
cin>>m;
int f=;
for(int i=; i<m; i++)
{
int x;
cin>>x;
if(!M[x])
{
f=;
break;
}
else M[x]--;
}
cout<<(f?"NO\n":"YES\n");
return ;
}

C - 3 Steps


Time limit : 2sec / Memory limit : 256MB

Score : 500 points

Problem Statement

Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices Ai and Bi.

Rng will add new edges to the graph by repeating the following operation:

  • Operation: Choose u and v (uv) such that Vertex v can be reached by traversing exactly three edges from Vertex u, and add an edge connecting Vertices uand v. It is not allowed to add an edge if there is already an edge connecting Vertices u and v.

Find the maximum possible number of edges that can be added.

Constraints

  • 2≤N≤105
  • 1≤M≤105
  • 1≤Ai,BiN
  • The graph has no self-loops or multiple edges.
  • The graph is connected.

Input

Input is given from Standard Input in the following format:

N M
A1 B1
A2 B2
:
AM BM

Output

Find the maximum possible number of edges that can be added.


Sample Input 1

Copy
6 5
1 2
2 3
3 4
4 5
5 6

Sample Output 1

Copy
4

If we add edges as shown below, four edges can be added, and no more.


Sample Input 2

Copy
5 5
1 2
2 3
3 1
5 4
5 1

Sample Output 2

Copy
5

Five edges can be added, for example, as follows:

  • Add an edge connecting Vertex 5 and Vertex 3.
  • Add an edge connecting Vertex 5 and Vertex 2.
  • Add an edge connecting Vertex 4 and Vertex 1.
  • Add an edge connecting Vertex 4 and Vertex 2.
  • Add an edge connecting Vertex 4 and Vertex 3.

搞成二分图然后dfs啊

然后再利用六哥的两边的个数想乘就好了

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
bool f=;
int c[N],cnt[];
vector<int>G[N];
void dfs(int x,int ff=)
{
if(c[x])
{
f|=ff!=c[x];
return;
}
c[x]=ff;
cnt[ff]++;
for(int u:G[x])
dfs(u,-ff);
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=; i<m; ++i)
{
int u,v;
scanf("%d%d",&u,&v);
G[u].push_back(v);
G[v].push_back(u);
}
dfs();
printf("%lld\n",f?1LL*n*(n-)/-m:1LL*cnt[]*cnt[]-m);
return ;
}

CODE FESTIVAL 2017 qual B的更多相关文章

  1. CODE FESTIVAL 2017 qual B B - Problem Set【水题,stl map】

    CODE FESTIVAL 2017 qual B B - Problem Set 确实水题,但当时没想到map,用sort后逐个比较解决的,感觉麻烦些,虽然效率高很多.map确实好写点. 用map: ...

  2. CODE FESTIVAL 2017 qual B C - 3 Steps【二分图】

    CODE FESTIVAL 2017 qual B C - 3 Steps 题意:给定一个n个结点m条边的无向图,若两点间走三步可以到,那么两点间可以直接连一条边,已经有边的不能连,问一共最多能连多少 ...

  3. 【题解】Popping Balls AtCoder Code Festival 2017 qual B E 组合计数

    蒟蒻__stdcall终于更新博客辣~ 一下午+一晚上=一道计数题QAQ 为什么计数题都这么玄学啊QAQ Prelude 题目链接:这里是传送门= ̄ω ̄= 下面我将分几个步骤讲一下这个题的做法,大家不 ...

  4. Atcoder CODE FESTIVAL 2017 qual C D - Yet Another Palindrome Partitioning 回文串划分

    题目链接 题意 给定一个字符串(长度\(\leq 2e5\)),将其划分成尽量少的段,使得每段内重新排列后可以成为一个回文串. 题解 分析 每段内重新排列后是一个回文串\(\rightarrow\)该 ...

  5. Atcoder CODE FESTIVAL 2017 qual C C - Inserting 'x' 回文串

    题目链接 题意 给定字符串\(s\),可以在其中任意位置插入字符\(x\). 问能否得到一个回文串,若能,需插入多少个\(x\). 思路 首先统计出现次数为奇数的字符\(cnt\). \(cnt\ge ...

  6. Atcoder CODE FESTIVAL 2017 qual B E - Popping Balls 组合计数

    题目链接 题意 \(A+B\)个球排成一行,左边\(A\)个为红球,右边\(B\)个为蓝球. 最开始可以选择两个数\(s,t\),每次操作可以取左起第\(1\)或\(s\)或\(t\)个球.问有多少种 ...

  7. Atcoder CODE FESTIVAL 2017 qual B D - 101 to 010 dp

    题目链接 题意 对于一个\(01\)串,如果其中存在子串\(101\),则可以将它变成\(010\). 问最多能进行多少次这样的操作. 思路 官方题解 转化 倒过来考虑. 考虑,最终得到的串中的\(' ...

  8. Atcoder CODE FESTIVAL 2017 qual B C - 3 Steps 二分图

    题目链接 题意 给定一个无向图,\(n\)个点,\(m\)条边(\(n,m\leq 1e5\)). 重复如下操作: 选择相异的两点u,v满足从点u出发走三条边恰好能到达点v.在这样的u,v点对之间添一 ...

  9. [Atcoder Code Festival 2017 Qual A Problem D]Four Coloring

    题目大意:给一个\(n\times m\)的棋盘染四种颜色,要求曼哈顿距离为\\(d\\)的两个点颜色不同.解题思路:把棋盘旋转45°,则\((x,y)<-(x+y,x-y)\).这样就变成了以 ...

随机推荐

  1. shell函数的使用

    shell函数的使用比较简单,要点包括定义.参数来源.返回值: 在shell函数里,结合read命令,可以实现在执行脚本的过程中让用户选择参数,增强脚本的交互性: 脚本参数在脚本名称后面输入,函数参数 ...

  2. db2数据库备份

    一.离线备份 db2  list  database  directory -----查看有哪些数据库,确定需要备份哪个数据库 db2  disconnect  current -----断开以数据库 ...

  3. Web端 年月日下拉表 密码判断 按钮判断是否提交

    生日: <asp:DropDownList ID="selYear" runat="server"></asp:DropDownList> ...

  4. 洛谷 P1074 靶形数独

    题目描述 小城和小华都是热爱数学的好学生,最近,他们不约而同地迷上了数独游戏,好胜的他 们想用数独来一比高低.但普通的数独对他们来说都过于简单了,于是他们向 Z 博士请教, Z 博士拿出了他最近发明的 ...

  5. 洛谷 P3019 [USACO11MAR]会见点Meeting Place

    题目背景 征求翻译.如果你能提供翻译或者题意简述,请直接发讨论,感谢你的贡献. 题目描述 Bessie and Jonell are great friends. Since Farmer John ...

  6. Java的三大特性之继承

    此处我会分为这几个部分来理解继承是怎么样的: 1.区分封装.继承和多态 2.区分限定词的范围 3.区分隐藏.覆盖.重载 4.继承的理解 5.一道面试题的原型 --------------------- ...

  7. 2d游戏中的射线与矩形检测碰撞

    cc.exports.LineCollideRect(startLine,endLine,rect)--向量与矩形检测碰撞 --获取矩形的四个顶点位置 local p = {cc.p(rect.x,r ...

  8. c++结构体双关键字排序

    #include<bits/stdc++.h> using namespace std; struct node{ int l,r; }num[]; int w_comp(const no ...

  9. mysql 在线添加字段

    使用工具pt-online-schema-change #! /bin/bash stime=`date +%s` echo "增加字段开始测试时间为:`date +%H:%M:%S`&qu ...

  10. 初识Mysql之基本简单语法总结

    一.  DDL(data definition language)语句:数据定义语言. 这些语句定义了不同的数据段.数据库.表.列.索引等数据库对象.常用语句关键字:create.drop.alter ...