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

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. css隐藏元素的几种方法与区别

    css隐藏元素的几种方法与区别 一:display:none;隐藏不占位 display 除了不能加入 CSS3 动画豪华大餐之外,基本效果卓越,没什么让人诟病的地方. 二:position:abso ...

  2. 晒一下MAC下终端颜色配置

    效果图: ~/.vimrc 配置 filetype on set history=1000 set background=dark syntax on set autoindent set smart ...

  3. 菜鸟的数据库实战-4-数据阅读器SqlDataReader

    老铁们大家好啊,我是菜鸟思奎,今天我学习的是数据库和前端的连接用到的字符串,如果有什么纰漏希望大家在评论区指正.阿里嘎多. 我的环境是Visual Studio 2008 + Microsoft SQ ...

  4. Mongodb之failed to create service entry worker thread

    Mongodb "failed to create service entry worker thread" 错误. 系统:CentOS release 6.8 mongod.lo ...

  5. Codeforces Round #321 (Div. 2) B. Kefa and Company (尺取)

    排序以后枚举尾部.尺取,头部单调,维护一下就好. 排序O(nlogn),枚举O(n) #include<bits/stdc++.h> using namespace std; typede ...

  6. 广播监听USB插入与拔出

    package com.joy.usbbroadcastreceiver; import android.content.BroadcastReceiver; import android.conte ...

  7. Ab initio methods|Evidence-based methods|maximum-likelihood|branch-site|H1|H0|GO|dS/dN ratio

    (Gene prediction and comparison) 使用基于基因组序列的从头预测方法(Ab initio methods)(同时分别使用头预测软件( GENSCAN和 AUGUSTUS) ...

  8. Mybatis学习记录(2)

    1.mybatis与hibernate不同 Mybatis和hibernate,mybatis不完全是一个ORM框架,因为Mybatis需要程序员自己编写sql语句.mybatis可以通过xml或注解 ...

  9. Nuget使用备忘

    菜单:工具-库程序包管理器-管理解决方案的NuGet程序包,搜索,下载,安装 或者 工具-库程序包管理器-程序包管理器控制台,输入PM命令,如: install-package log4net 如果不 ...

  10. nodejs写一个简单的Web服务器

    目录文件如 httpFile.js如下: const httpd = require("http"); const fs = require("fs"); // ...