CODE FESTIVAL 2017 qual B
昨晚因为有点事就去忙了,没打后悔啊
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
CODEFESTIVAL
Sample Output 1
CODE
This is the same as the example in the statement.
Sample Input 2
CODEFESTIVALFESTIVAL
Sample Output 2
CODEFESTIVAL
This string is obtained by appending FESTIVAL
to the end of CODEFESTIVAL
, so it is a festival of CODEFESTIVAL
.
Sample Input 3
YAKINIKUFESTIVAL
Sample Output 3
YAKINIKU
#include<bits/stdc++.h> using namespace std; int main() {string s;cin>>s;int l=s.length()-8;for(int i=0; i<l; ++i)putchar(s[i]);return 0; }
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
5 3 1 4 1 5 3 5 4 3
Sample Output 1
YES
Sample Input 2
7 100 200 500 700 1200 1600 2000 6 100 200 500 700 1600 1600
Sample Output 2
NO
Not enough 1600s.
Sample Input 3
1 800 5 100 100 100 100 100
Sample Output 3
NO
Sample Input 4
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
YES
用map看一下数据是否合法就行了
#include<bits/stdc++.h> using namespace std; map<int,int>M; int main() {int n,m;cin>>n;for(int i=0; i<n; i++){int x;cin>>x,M[x]++;}cin>>m;int f=0;for(int i=0; i<m; i++){int x;cin>>x;if(!M[x]){f=1;break;}else M[x]--;}cout<<(f?"NO\n":"YES\n");return 0; }
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 (u≠v) 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,Bi≤N
- 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
6 5 1 2 2 3 3 4 4 5 5 6
Sample Output 1
4
If we add edges as shown below, four edges can be added, and no more.
Sample Input 2
5 5 1 2 2 3 3 1 5 4 5 1
Sample Output 2
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+5; bool f=0; int c[N],cnt[3]; vector<int>G[N]; void dfs(int x,int ff=1) {if(c[x]){f|=ff!=c[x];return;}c[x]=ff;cnt[ff]++;for(int u:G[x])dfs(u,3-ff); } int main() {int n,m;scanf("%d%d",&n,&m);for(int i=0; i<m; ++i){int u,v;scanf("%d%d",&u,&v);G[u].push_back(v);G[v].push_back(u);}dfs(1);printf("%lld\n",f?1LL*n*(n-1)/2-m:1LL*cnt[1]*cnt[2]-m);return 0; }
转载于:https://www.cnblogs.com/BobHuang/p/7639623.html
CODE FESTIVAL 2017 qual B相关推荐
- [Atcoder Code Festival 2017 Qual A Problem F] Squeezing Slimes
原题链接:https://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_f Squeezing ...
- [Code Festival 2017 qual A-F] Squeezing Slimes
Atcoder传送门 题目大意 给你一个长度为NNN的序列a1,a2,a3,....,aN" role="presentation" style="positi ...
- Code Festival 2017 qualA E-Modern Painting
DescriptionDescription 给定一个n∗mn*m的网格.一些人站在网格的边界上. 一个人可以占据他面前的一行(列),过程是一直往前染色(每个人的颜色都不一样),直到下一个格子染上了颜 ...
- Google Code Jam 2017 资格赛
https://code.google.com/codejam/contest/3264486/dashboard#s=p3 Oversized Pancake Flipper (1)问题描述: Pr ...
- [CODE FESTIVAL 2016]Distance Pairs
题意:有一个未知的边权为$1$的图,给定所有点到$1$的最短路$a_i$和到$2$的最短路$b_i$,问是否存在这样的图,如果存在,问图中最少有多少条边 先考虑$a_i$,有$a_1=0,a_i\ne ...
- RCC 2017 Qual 1 Mail.Ru, April 2, 2017 Problem B. Painting the Wall
题意:给一个n*m(<=100)的图,图中0表示台灯,1表示空地,以台灯和墙作为边界,问能否使用k种使得联通的线段上没有重复的颜色 分析:只要连续的空地不超过k个就必然存在一个解,可以选择如下构 ...
- Code Jam 2017 Qualification Round Problem A. Oversized Pancake Flipper
题目 给定字符串 S 由+或-组成和 K ,现有一种操作:能将串 S 中连续 K 个字符进行反转( + 变成-以及 -变成+ ).问最少进行多少次上述操作,可以把串 S 变成全由 + 组成.当然也可能 ...
- 2020.7月做题记录
转眼就到了2020的下半年了-前方仍是一片茫然. 长期计划 prufer 序列 2020.07.02-2020.07.04 Problem Finished P2624 [HNOI2008]明明的烦恼 ...
- NOIP2016考前做题(口胡)记录
NOIP以前可能会持续更新 写在前面 NOIP好像马上就要到了,感觉在校内训练里面经常被虐有一种要滚粗的感觉(雾.不管是普及组还是提高组,我都参加了好几年了,结果一个省一都没有,今年如果还没有的话感觉 ...
最新文章
- 福布斯2015中国非上市潜力企业100强
- python 获取指定文件夹里面的图片文件的信息
- JAVA程序设计----集合基础之Map
- 《深入浅出nodejs》读书笔记(3)
- android layerlist bitmap,android shape类似的 另一个 高端用法:layer-list
- python字符串截取split 失败_python如何截断字符串
- hdu-1862-EXCEL排序
- 卷积神经网络训练准确率突然下降_详解卷积神经网络:手把手教你训练一个新项目...
- 【历史上的今天】8 月 17 日:Oracle 创始人出生;第一个 COBOL 程序成功跑通!...
- mongodb官网文档阅读笔记:write concern
- 在git 2.13之前,只保存多个已更改的文件中的一个文件
- 算法笔记_面试题_21.数据结构相关_模板及示例十几道
- nodejs个人学习笔记
- c语言头文件下载大全,C语言头文件大全
- tempo.js模板引擎:通过tempo将Json串填充到html页面中
- h5/web 原生定位、高德、腾讯地图定位
- 随机密码生成Python
- PHP等比缩放并补白
- 戴尔PC,“传奇”要怎样延续?
- 在线检查英文语法神器
热门文章
- Windows2003无法看到网络连接,修复COM+组件
- [FLASH_AS]Flash as3 addEventListener事件监听传递参数
- 产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。
- 盛趣游戏 html5游戏,盛趣游戏谭雁峰:游戏破局的“精细”时代已来
- sqlite库——C实现,给sqlite数据库添加信息并把信息写入文件,删除日志和库中的日志信息
- 【AMAD】import-string -- 通过字符串来import一个对象
- python 网络编程--socket模块/struct模块
- Navicat数据库备份还原
- HDU 1426 Sudoku Killer【DFS 数独】
- 使用python进行utf9编码和解码