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

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. xcdatamodel的实质

    修改后缀名为zip或者其它,可以查看到xcdatamodel是一个描述文件 <?xml version="1.0" encoding="UTF-8" st ...

  2. AWVS12 防止反复注册

    以管理员权限运行cmd,输入以下内容: cacls "C:\ProgramData\Acunetix\shared\license." /t /p everyone:r 如图:

  3. nginx的工作流程

    nginx请求处理流程 nginx进程结构 master进程:是作为worker进程管理的 worker进程:处理真正的请求的而master进程则是管控这些进程的工作方式的:缓存是在多个worker进 ...

  4. Problem O: 国家排序

    Problem O: 国家排序 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 405  Solved: 253[Submit][Status][Web ...

  5. MySQL 数据备份与还原的示例代码

    MySQL 数据备份与还原的示例代码 这篇文章主要介绍了MySQL 数据备份与还原的相关知识,本文通过示例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 一.数据备份 1.使用 ...

  6. Chunky Monkey-freecodecamp算法题目

    Chunky Monkey(猴子吃香蕉, 分割数组) 要求 把一个数组arr按照指定的数组大小size分割成若干个数组块. 思路 利用size值和while语句确定切割数组的次数(定义temp将siz ...

  7. 【思维题 线段树】cf446C. DZY Loves Fibonacci Numbers

    我这种maintain写法好zz.考试时获得了40pts的RE好成绩 In mathematical terms, the sequence Fn of Fibonacci numbers is de ...

  8. mysql 备份 常用脚本

    全备: innobackupex --defaults-file=/data/mysql3316/my3316.cnf --user=root --password=mysqlpass /data/b ...

  9. centOS下lnamp安装

    首先安装apache,mysql ,最后安装php 1>apache安装 安装:yum install -y httpd 运行:/bin/systemctl start httpd.servic ...

  10. python入门:最基本的用户登录用户登录,三次错误机会

    #!/usr/bin/env python # -*- coding:utf-8 -*- #用户登录,三次错误机会 """ 导入getpass,给x赋值为1,while真 ...