Codeforces 659 - A/B/C/D/E/F/G - (Undone)
链接: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)的更多相关文章
- Codeforces 1154 - A/B/C/D/E/F/G - (Undone)
链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...
- 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 ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- codeforces 659 G. Fence Divercity 组合数学 dp
http://codeforces.com/problemset/problem/659/G 思路: f(i,0/1,0/1) 表示到了第i个,要被切的块开始了没有,结束了没有的状态的方案数 递推看代 ...
- 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 ...
- 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\),可加 ...
- Codeforces 670 - A/B/C/D/E/F - (Done)
链接:https://codeforces.com/contest/670 A - Holidays - [水] AC代码: #include<bits/stdc++.h> using n ...
- Codeforces 1132 - A/B/C/D/E/F - (Undone)
链接:http://codeforces.com/contest/1132 A - Regular Bracket Sequence - [水] 题解:首先 "()" 这个的数量多 ...
- Codeforces 1114 - A/B/C/D/E/F - (Undone)
链接:http://codeforces.com/contest/1114 A - Got Any Grapes? 题意:甲乙丙三个人吃葡萄,总共有三种葡萄:绿葡萄.紫葡萄和黑葡萄,甲乙丙三个人至少要 ...
随机推荐
- iOS实现 webView loadHTMLString加载外部css、js样式
记录一下. webview(或wk)用 loadHTMLString加载内容时 ,如果只是单纯的html内容,样式等都写在内部,直接设置baseURL为nil即可. 不过当html里包含外部样式或调用 ...
- centos mysql密码忘记了如何修改
# /etc/init.d/mysql stop# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# mysq ...
- 【C++】C++中const与constexpr的比较
先说结论相同点:const和consexpr都是用来定义常量的.不同点:const声明的常量,初始值引用的对象不一定是一个常量:constexpr声明的常量,初始值一定是常量表达式. constexp ...
- 在IIS7上导出所有应用程序池的方法批量域名绑定(网站绑定)
资料来源: http://www.2cto.com/os/201410/341882.html 一点经验:导出配置文件后,建议打开看看,如果有需要调整的需要做修改. 在IIS7+上导出所有应用程序池的 ...
- C#获取中国天气网免费天气预报信息
中国天气网接口地址:”http://wthrcdn.etouch.cn/WeatherApi?citykey=” + weatherCityCode(为城市code); 下面是转化过程中我们需要用到的 ...
- Linux基础知识之用户和用户组以及 Linux 权限管理
已经开始接触Linux用户管理,用户组管理,以及权限管理这几个逼格满满的关键字.这几个关键字对于前端程序猿的我来说真的是很高大上有木有,以前尝试学 Linux 的时候看到这些名词总是下意识的跳过不敢看 ...
- IDEA设置换行符为Unix编码格式,设置编码统一为UTF-8,自动生成serialVersionUID
设置换行符为Unix编码格式 设置编码统一为UTF-8 自动生成serialVersionUID.勾选"Serializable class without serialVersionUID ...
- com.android.jack.CommandLine: Internal compiler error
Android studio编译的时候出现错误: SEVERE: com.android.jack.CommandLine: Internal compiler error Error:Executi ...
- 同样:Hashtable较HashMap也是如此。
练习: ① 存车位的停开车的次序输出问题: ② 写两个线程,一个线程打印1-52,另一个线程答应字母A-Z.打印顺序为12A34B56C……5152Z.通过使用线程之间的通信协调关系. 注:分 ...
- 再整合ssh时,关于Spring IOC注入问题
No matching editors or conversion strategy found IOC问题: EmpService bean 实现了 Iemp接口,就不能直接作为参数传入Action ...