第七届福建省大学生程序设计竞赛
训练赛 ——第七届福建省大学生程序设计竞赛
rank 68/250
一号签到题
solved by mwh 16:05
=#include <stdio.h> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <stack> #pragma GCC optimize(2) #define mm(i,v) memset(i,v,sizeof i); #define mp(a, b) make_pair(a, b) #define one first #define two second using namespace std; typedef long long ll; typedef pair<int, int > PII; const int N = 1e4 + 5, mod = 1e9 + 9, INF = 0x3f3f3f3f; int t, n; int a[N], b[N]; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // cin.tie(0); // cout.tie(0); // ios::sync_with_stdio(0); cin >> t; for (int k = 1; k <= t; ++k) { ll ans = 0; cin >> n; for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) scanf("%d", &b[i]); for (int i = 1; i <= n; ++i) { if (a[i] + b[i] > 10) ans ++; } printf("Case %d: %d\n", k, ans); } }
二号签到题
solved 40:57(-1)
#include <stdio.h> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <stack> #include <set> #pragma GCC optimize(2) #define mm(i,v) memset(i,v,sizeof i); #define mp(a, b) make_pair(a, b) #define one first #define two second using namespace std; typedef long long ll; typedef pair<int, int > PII; const int N = 1e6 + 5, mod = 1e9 + 9, INF = 0x3f3f3f3f; int t, n; int a[N], b[N]; int main() { cin >> t; for (int k = 1; k <= t; ++k) { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); } printf("Case %d: %.2lf\n", k, 1.0 * n / 2); } }
四号签到题
solved by mwh 01:55:25
可以发现只需枚举第一个数组中的每个数,把第二个数组中比改数小的数字个数加起来,这个和和除以n就可
可以直接用二分搜索,时间复杂度O(nlogn)
#include <stdio.h> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <stack> #pragma GCC optimize(2) #define mm(i,v) memset(i,v,sizeof i); #define mp(a, b) make_pair(a, b) #define one first #define two second using namespace std; typedef long long ll; typedef pair<int, int > PII; const int N = 1e6 + 5, mod = 1e9 + 9, INF = 0x3f3f3f3f; int t, n; int a[N], b[N]; double ans = 0; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // cin.tie(0); // cout.tie(0); // ios::sync_with_stdio(0); cin >> t; for (int k = 1; k <= t; ++k) { cin >> n; for (int i = 0; i < n; ++i) scanf("%d", &a[i]); for (int i = 0; i < n; ++i) scanf("%d", &b[i]); sort(a, a + n); sort(b, b + n); ans = 0; for (int i = 0; i < n; ++i) { ans += (lower_bound(b, b + n, a[i]) - b); } printf("Case %d: %.2lf\n", k, ans / n); } }
三号签到题
直接1、2、4、8.......就可
题目非常简单,但是不知道为什么原因一直WA,这题也直接导致了我队前期节奏爆炸,导致罚时发炸
后来队友对着这题自闭自闭一个多小时后把long long改成int就过了
solved by rst 01:18:38(-3)
#include <stdio.h> int main() { int t, d; scanf("%d", &t); int k = 0; while(t--) { int ans = 0; scanf("%d", &d); while(d) { d /= 2; ans++; } printf("Case %d: %d\n", ++k, ans); } }
显然就是一道floyd的题目
solved by mwh 02:59:35(-3)
#include <stdio.h> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <stack> #define mm(i,v) memset(i,v,sizeof i); #define mp(a, b) make_pair(a, b) #define one first #define two second using namespace std; typedef long long ll; typedef pair<int, int > PII; const int N = 110, mod = 1e9 + 9, INF = 0x3f3f3f3f; int t, n, m, ans; int vis[N][N]; int d[N][N]; map<PII, int> q; int main() { cin >> t; for (int k = 1; k <= t; ++k) { ans = 0; q.clear(); scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { d[i][j] = INF; d[j][i] = INF; vis[i][j] = 0; vis[j][i] = 0; } for (int i = 1; i <= m; ++i) { int x, y, z; scanf("%d%d%d", &x, &y, &z); if (vis[x][y] != 0) { if (vis[x][y] <= z) { ans++; } else { vis[x][y] = z; vis[y][x] = z; d[x][y] = min(d[x][y], z); d[y][x] = min(d[y][x], z); ans++; } } else { vis[x][y] = z; vis[y][x] = z; d[x][y] = min(d[x][y], z); d[y][x] = min(d[y][x], z); } } for (int p = 1; p <= n; ++p) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (d[i][p] + d[p][j] <= d[i][j]) { d[i][j] = d[i][p] + d[p][j]; if (vis[i][j] != 0) { ans++; vis[i][j] = 0; vis[j][i] = 0; } } } } } printf("Case %d: %d\n", k, ans); } }
笨比mwh自闭一个多小时,赛后问nb室友xwd发现我好像想的有点多?
unsolved by mwh
大概是一道计算几何?反正我看都没看,两个队友对着他开始了模拟,看了一眼代码人都傻了
unsolved by czw&rst