Codeforces Round #346 (Div. 2) ABCDE
来源:互联网 发布:拉货搬家软件 编辑:程序博客网 时间:2024/06/05 15:17
题目:http://codeforces.com/contest/659/problems
A:
#include <iostream>#include <string>using namespace std;int n, a, b;int main(){ while (cin >> n >> a >> b) { int ans; ans = (a + b + n * 1000) % (n); if (ans == 0) ans = n; cout << ans << endl; } return 0;}
B:
#include <iostream>#include <string>#include <algorithm>#include <vector>using namespace std;vector <pair<int, string>> a[10010];int n, m;int main(){ while (cin >> n >> m) { string tmp; int num, val; for (int i = 1;i <= n;i++) { cin >> tmp >> num >> val; num--; val = -val; a[num].push_back(make_pair(val, tmp)); } for (int i = 0;i < m;i++) { sort(a[i].begin(), a[i].end()); if (a[i].size() > 2 && a[i][1].first == a[i][2].first) puts("?"); else cout << a[i][0].second <<" "<< a[i][1].second << endl; } } return 0;}
C:
#include <iostream>#include <string>#include <algorithm>#include <vector>#include <set>using namespace std;int n, m;set<int> S;vector<int> ans;int main(){ while (cin >> n >> m) { ans.clear(); S.clear(); set<int>::iterator pos; vector<int>::iterator it; int tmp; for (int i = 1;i <= n;i++) { cin >> tmp; S.insert(tmp); } tmp = 1; while (m) { if (m < tmp) break; if (S.count(tmp) == 0) { m -= tmp; ans.push_back(tmp); S.insert(tmp); tmp++; } else tmp++; } cout << ans.size() << endl; for (it = ans.begin();it != ans.end();it++) cout << *it << " "; cout << endl; } return 0;}
D:
#include <iostream>#include <string>#include <algorithm>#include <vector>#include <set>using namespace std;int n;struct{ int x, y;}a[1010];int main(){ while (scanf("%d", &n) != EOF) { memset(b, 0, sizeof(b)); for (int i = 0;i <= n;i++) { scanf("%d %d", &a[i].x, &a[i].y); } int ans = 0; for (int i = 0;i < n;i++) { int t1 = i + 1; int t2 = i + 2; if (t2 == n + 1) t2 = 0; if (a[i].x < a[i + 1].x && a[i].y == a[i + 1].y)//右 { if (a[t1].x == a[t2].x && a[t1].y < a[t2].y)//↑ ans++; } else if (a[i].x > a[i + 1].x && a[i].y == a[i + 1].y)//左 { if (a[t1].x == a[t2].x && a[t1].y > a[t2].y)//下 ans++; } else if (a[i].x == a[i + 1].x && a[i].y < a[i + 1].y)//上 { if (a[t1].x > a[t2].x && a[t1].y == a[t2].y)//左 ans++; } else if (a[i].x == a[i + 1].x && a[i].y > a[i + 1].y)//下 { if (a[t1].x < a[t2].x && a[t1].y == a[t2].y)//右 ans++; } } printf("%d\n", ans); } return 0;}
E:
#include <iostream>#include <string>#include <algorithm>#include <vector>#include <set>using namespace std;const int MAXN = 200010;vector<int> g[MAXN];int n, m, nnode, nedge;int vis[MAXN];void dfs(int u){ vis[u] = 1; nnode++; for (int i = 0;i < g[u].size();i++) { int v = g[u][i]; nedge++; if (!vis[v]) dfs(v); }}int main(){ while (scanf("%d %d", &n, &m) != EOF) { memset(vis, 0, sizeof vis); for (int i = 0;i <= n;i++) g[i].clear(); int u, v; for (int i = 1;i <= m;i++) { scanf("%d %d", &u, &v); g[u].push_back(v); g[v].push_back(u); } int ans = 0; for (int i = 1;i <= n;i++) { if (!vis[i]) { nnode = nedge = 0; dfs(i); if (nedge / 2 == nnode - 1) ans++; } } printf("%d\n", ans); } return 0;}
0 0
- Codeforces Round #346 (Div. 2) ABCDE
- Codeforces Round #198(Div.2)ABCDE
- Codeforces Round #261 (Div. 2)[ABCDE]
- Codeforces Round #264 (Div. 2)[ABCDE]
- Codeforces Round #293 (Div. 2) (ABCDE题解)
- Codeforces Round #294 (Div. 2) ABCDE
- Codeforces Round #294 (Div. 2) (ABCDE题解)
- Codeforces Round #296 (Div. 2) (ABCDE题解)
- Codeforces Round #297 (Div. 2) (ABCDE题解)
- 【CF】Codeforces Round #301 (Div. 2) ABCDE
- Codeforces Round #240 (Div. 2) (ABCDE题解)
- Codeforces Round #313 (Div. 2) (ABCDE题解)
- Codeforces Round #105 (Div. 2) (ABCDE题解)
- Codeforces Round #200 (Div. 2) (ABCDE题解)
- Codeforces Round #186 (Div. 2) (ABCDE题解)
- Codeforces Round #337 (Div. 2) ABCDE
- Codeforces Round #338 (Div. 2) ABCDE
- Codeforces Round #350 (Div. 2) ABCDE
- HTML学习笔记(十四)URL
- leetcode之Power of Two
- 1003. Emergency
- 我的linux学习之路:Git常用命令
- 蓝桥杯单片机设计与开发笔记(四)
- Codeforces Round #346 (Div. 2) ABCDE
- POJ 2114 Boatherds 点分治
- Java集合---ConcurrentHashMap原理分析
- IOSRadioGroup
- 数据结构之“堆”
- Android Linux内核编译调试
- unity3D ~ 视频播放
- HDU4331 Image Recognition
- 环境配置中path和classpath的作用