链接:https://codeforces.com/contest/659


A - Round House - [取模]

AC代码:

#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main()
{
cin>>n>>a>>b;
a=(a-+b);
while(a<) a+=n;
a%=n;
cout<<a+<<endl;
}

B - Qualifying Contest - [水]

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
const int maxm=1e4+;
int n,m;
struct P{
string name;
int reg,sco;
bool operator<(const P& o)const {
return sco>o.sco;
}
}p;
vector<P> R[maxm];
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>m;
for(int i=;i<=n;i++)
{
cin>>p.name>>p.reg>>p.sco;
R[p.reg].push_back(p);
} for(int i=;i<=m;i++)
{
sort(R[i].begin(),R[i].end());
if(R[i].size()> && R[i][].sco<=R[i][].sco) cout<<"?\n";
else cout<<R[i][].name<<" "<<R[i][].name<<'\n';
}
}

C - Tanya and Toys - [贪心水题]

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
int n,m;
map<int,bool> mp;
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>m;
mp.clear();
for(int i=,x;i<=n;i++) cin>>x, mp[x]=; vector<int> ans;
for(int i=;i<=(int)1e9;i++)
{
if(mp[i]) continue;
if(m>=i) ans.push_back(i), m-=i;
else break;
}
cout<<ans.size()<<'\n';
for(auto x:ans) cout<<x<<' ';
}

D - Bicycle Race - [叉乘]

AC代码:

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define mk(x,y) make_pair(x,y)
#define fi first
#define se second
const int maxn=1e3+;
int n;
P p[maxn];
int cross(P a,P b)
{
return a.fi*b.se-b.fi*a.se;
}
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n;
for(int i=;i<n+;i++) cin>>p[i].fi>>p[i].se;
int cnt=;
for(int i=;i<n;i++)
{
P pre=mk(p[i].fi-p[(i-+n)%n].fi,p[i].se-p[(i-+n)%n].se);
P nxt=mk(p[(i+)%n].fi-p[i].fi,p[(i+)%n].se-p[i].se);
if(cross(pre,nxt)>) cnt++;
}
cout<<cnt<<endl;
}

E - New Reform - [DFS判环]

题解:对于一个子图,如果存在环,那么肯定可以做到没有一个城市没有入弧;如果一个子图是一棵树,那么可以任选一个城市作为根,只有该城市没有入弧,答案增加一。

AC代码:

#include<bits/stdc++.h>
#define pb(x) push_back(x)
using namespace std;
const int maxn=1e5+;
int n,m;
vector<int> g[maxn];
bool vis[maxn]; bool flag;
void dfs(int x,int pre)
{
vis[x]=;
for(auto y:g[x])
{
if(y==pre) continue;
if(!vis[y]) dfs(y,x);
else flag=;
}
}
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>m;
for(int i=,x,y;i<=m;i++)
{
cin>>x>>y;
g[x].pb(y), g[y].pb(x);
} int cnt=;
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++)
{
if(vis[i]) continue;
flag=;
dfs(i,-);
if(!flag) cnt++;
}
cout<<cnt<<endl;
}

Codeforces 659 - A/B/C/D/E/F/G - (Undone)的更多相关文章

  1. Codeforces 1154 - A/B/C/D/E/F/G - (Undone)

    链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...

  2. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  3. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  4. codeforces 659 G. Fence Divercity 组合数学 dp

    http://codeforces.com/problemset/problem/659/G 思路: f(i,0/1,0/1) 表示到了第i个,要被切的块开始了没有,结束了没有的状态的方案数 递推看代 ...

  5. Codeforces Bubble Cup 8 - Finals [Online Mirror] F. Bulbo DP

    F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Des ...

  6. Educational Codeforces Round 58 (Rated for Div. 2) F dp + 优化(新坑) + 离线处理

    https://codeforces.com/contest/1101/problem/F 题意 有n个城市,m辆卡车,每辆卡车有起点\(s_i\),终点\(f_i\),每公里油耗\(c_i\),可加 ...

  7. Codeforces 670 - A/B/C/D/E/F - (Done)

    链接:https://codeforces.com/contest/670 A - Holidays - [水] AC代码: #include<bits/stdc++.h> using n ...

  8. Codeforces 1132 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1132 A - Regular Bracket Sequence - [水] 题解:首先 "()" 这个的数量多 ...

  9. Codeforces 1114 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1114 A - Got Any Grapes? 题意:甲乙丙三个人吃葡萄,总共有三种葡萄:绿葡萄.紫葡萄和黑葡萄,甲乙丙三个人至少要 ...

随机推荐

  1. Ubuntu 16.04 升级git

    To update git on Ubuntu 12.04 just follow this line of commands: sudo apt-get install python-softwar ...

  2. WPF相关网址

    5.http://code.msdn.microsoft.com 4.仿真模拟多点触控:http://tinyurl.com/yawwhw2http://multitouchvista.codeple ...

  3. Java基础(四)线程快速了解

    开始整理线程之前,之前有个命令忘记整理了,先整理一下jar命令的使用 Jar包 其实可以理解是java的压缩包方便使用,只要在classpath设置jar路径即可数据库驱动,ssh框架等都是以jar包 ...

  4. Atitit orm的实现模式 data-mapper模式和active-record模式有什么区别

    Atitit orm的实现模式  data-mapper模式和active-record模式有什么区别 1.1. 这是来自Node.js路线有关混合两种ORM模式Active Record(活动记录模 ...

  5. 基于Spring aop写的一个简单的耗时监控

    前言:毕业后应该有一两年没有好好的更新博客了,回头看看自己这一年,似乎少了太多的沉淀了.让自己做一个爱分享的人,好的知识点拿出来和大家一起分享,一起学习. 背景: 在做项目的时候,大家肯定都遇到对一些 ...

  6. 配置Windows 2008 R2 防火墙允许远程访问SQL Server 2008 R2

    1.先修改 sql server 2008R2的端口号吧,1433经常成为别人入侵的端口,在sql server 配置管理器 -->sql server 网络配置-->MSSQLSERVE ...

  7. 从MySQL Bug#67718浅谈B+树索引的分裂优化(转)

    原文链接:http://hedengcheng.com/?p=525 问题背景 今天,看到Twitter的DBA团队发布了其最新的MySQL分支:Changes in Twitter MySQL 5. ...

  8. hdoj:2051

    #include <iostream> #include <string> #include <vector> #include <algorithm> ...

  9. Linux 文件特殊权限_013

    ***Linux 系统文件除了9位基本权限,还有额外3位特殊权限,分别是SUID(setuid),SGID(setgid),SBIT(sticky bit) 一.Linux 系统文件3位特殊权限位说明 ...

  10. [原创]Fashion汽车定位器拆解

    随着共享单车的爆发增长,定位方案被彻底激活.当下主流的共享单车都采用了MTK2503的方案(后续再详细分解),本文针对某商城热卖的汽车定位器进行拆解分析. 第一部分,定位器外观. 第二部分,拆解开壳, ...