链接: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. alibaba的springcloud孵化器项目

    Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案.此项目包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式 ...

  2. cpu使用过高的一次处理方法

    1.top查看使用情况 2.查看mysql里的线程,观察是否有长期运行或阻塞的sql: show full processlist 原因找到,处理方法,添加索引,搞定

  3. Android开发导出apk报错:Unable to build: the file dx.jar was not loaded from the SDK folder

    问题背景 此问题一般出现在,同时使用了Eclipse和Android Studio,eclipse是不会去下载最新的Android的相关tools,但是studio有时候会自动更新最新的build-t ...

  4. 异类查询要求为连接设置ANSI_NULLS和ANSI_WARNINGS选项

    在查询分析器中,先输入两句    set   ansi_nulls   on    set   ansi_warnings   on    执行然后再    Create   Proc   存储过程  ...

  5. 查看和修改 mysql库、表、字段编码

    查看编码 查看数据库编码. show variables like '%char%'; 查看表编码 show create table <表名>; 例:show create table ...

  6. 面向对象的类关系及其C++实现

    在面向对象的程序设计中,类之间有6中关系,分别是继承, 组合, 聚合,关联, 依赖,实现,如果使用C语言实现,上面的这些关系通过"结构体包含结构体.结构体包含结构体指针以及函数指针等语法实现 ...

  7. Reading List on Automated Program Repair

    Some resources: https://www.monperrus.net/martin/automatic-software-repair 2017 [ ] DeepFix: Fixing ...

  8. LeetCode - 767. Reorganize String

    Given a string S, check if the letters can be rearranged so that two characters that are adjacent to ...

  9. [Golang] 开源一个帧同步服务器

    具体看README吧 https://github.com/bailu1901/lockstepserver

  10. Nestjs 上传文件

    Docs: https://docs.nestjs.com/techniques/file-upload 上传单文件 @Post('upload') @UseInterceptors(FileInte ...