T1 结论错误赛(R8-10.7)
死因:T1 结论错误。
完全炸了。
返乡(home)
期望得分
赛时思路:通过打表得知对于每个
正确思路:我们可以发现,对于
那我的错误思路为什么可以得到
赛时代码:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int kMaxN = 1e6 + 10;
int n, id, sz;
struct Node {
int a, b, c;
bool operator< (const Node &qwq) const {
if (a != qwq.a) {
return a < qwq.a;
}
if (b != qwq.b) {
return b < qwq.b;
}
return c < qwq.c;
}
} a[kMaxN];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i <= n; ++ i) {
for (int j = 0; j <= n; ++ j) {
int k = n - i + 1 - j;
if (k >= 0 && k <= n) {
a[++ id] = {i, j, k};
a[++ id] = {k, j, i};
}
}
}
sort(a + 1, a + id + 1);
for (int i = 1; i <= id; ++ i) {
if (!(a[i].a == a[i - 1].a && a[i].b == a[i - 1].b && a[i].c == a[i - 1].c)) {
++ sz;
}
}
cout << sz << '\n';
for (int i = 1; i <= id; ++ i) {
if (!(a[i].a == a[i - 1].a && a[i].b == a[i - 1].b && a[i].c == a[i - 1].c)) {
cout << a[i].a << ' ' << a[i].b << ' ' << a[i].c << '\n';
}
}
return 0;
}
正确代码:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int kMaxN = 1e6 + 10;
int n, id, sz;
struct Node {
int a, b, c;
bool operator< (const Node &qwq) const {
if (a != qwq.a) {
return a < qwq.a;
}
if (b != qwq.b) {
return b < qwq.b;
}
return c < qwq.c;
}
} a[kMaxN];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i <= n; ++ i) {
for (int j = 0; j <= n; ++ j) {
int k = (3 * n) / 2 - i - j;
if (k >= 0 && k <= n) {
a[++ id] = {i, j, k};
}
}
}
for (int i = 1; i <= id; ++ i) {
if (!(a[i].a == a[i - 1].a && a[i].b == a[i - 1].b && a[i].c == a[i - 1].c)) {
cout << a[i].a << ' ' << a[i].b << ' ' << a[i].c << '\n';
}
}
return 0;
}
连接(connect)
期望得分
赛时思路:纯暴力,枚举截取那个区间,算最大值。
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int kMaxN = 3e5 + 30;
ll n, L, R, l[kMaxN], p[kMaxN], a[kMaxN], id;
double ans;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> L >> R;
for (int i = 1; i <= n; ++ i) {
cin >> l[i];
}
for (int i = 1; i <= n; ++ i) {
cin >> p[i];
for (int j = 1; j <= l[i]; ++ j) {
a[++ id] = p[i];
}
}
for (int i = 1; i <= id; ++ i) {
for (int j = 1; j <= id; ++ j) {
ll sum = 0;
for (int k = i; k <= j; ++ k) {
sum += a[k];
}
if (sum >= L && sum <= R) {
ans = max(ans, (double)sum / (double)(j - i + 1));
}
}
}
cout << fixed << setprecision(9) << ans << '\n';
return 0;
}
习惯孤独(lone)
期望得分
本来想打个搜索,没时间了。
观察前两个样例,得出假结论为
显然不对。
车站(station)
期望得分
没有
显然,当
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int kMaxN = 1e5 + 10;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
if (k == n) {
cout << "0\n";
} else {
cout << "-1\n";
}
return 0;
}