2024.12.21 周六
2024.12.21 周六
Q1. 1000
Lottery "Three Sevens" was held for \(m\) days. On day \(i\), \(n_i\) people with the numbers \(a_{i, 1}, \ldots, a_{i, n_i}\) participated in the lottery.
It is known that in each of the \(m\) days, only one winner was selected from the lottery participants. The lottery winner on day \(i\) was not allowed to participate in the lottery in the days from \(i+1\) to \(m\).
Unfortunately, the information about the lottery winners has been lost. You need to find any possible list of lottery winners on days from \(1\) to \(m\) or determine that no solution exists.
Q2. 1000
Kristina has a string \(s\) of length \(n\), consisting only of lowercase and uppercase Latin letters. For each pair of lowercase letter and its matching uppercase letter, Kristina can get \(1\) burl. However, pairs of characters cannot overlap, so each character can only be in one pair.
For example, if she has the string \(s\) = "aAaaBACacbE", she can get a burl for the following character pairs:
- \(s_1\) = "a" and \(s_2\) = "A"
- \(s_4\) = "a" and \(s_6\) = "A"
- \(s_5\) = "B" and \(s_{10}\) = "b"
- \(s_7\)= "C" and \(s_9\) = "c"
Kristina wants to get more burles for her string, so she is going to perform no more than \(k\) operations on it. In one operation, she can:
- either select the lowercase character \(s_i\) (\(1 \le i \le n\)) and make it uppercase.
- or select uppercase character \(s_i\) (\(1 \le i \le n\)) and make it lowercase.
For example, when \(k\) = 2 and \(s\) = "aAaaBACacbE" it can perform one operation: choose \(s_3\) = "a" and make it uppercase. Then she will get another pair of \(s_3\) = "A" and \(s_8\) = "a"
Find maximum number of burles Kristina can get for her string.
Q3. 1000
You are given a two-dimensional plane, and you need to place \(n\) chips on it.
You can place a chip only at a point with integer coordinates. The cost of placing a chip at the point \((x, y)\) is equal to \(|x| + |y|\) (where \(|a|\) is the absolute value of \(a\)).
The cost of placing \(n\) chips is equal to the maximum among the costs of each chip.
You need to place \(n\) chips on the plane in such a way that the Euclidean distance between each pair of chips is strictly greater than \(1\), and the cost is the minimum possible.
------------------------独自思考分割线------------------------
-
Q1 Q3有些意思。1000分的题先到这,位运算,构造,数论,三者最难。
A1.
- 发现制约关系:当前答案的数后面的数组都不能出现。从后向前扫,未标记的数就可以作为答案。
- 这是必要性,需要证明一下充分性。
A2.
- 本质就是大小写匹配的次数,剩下的自己匹配自己(需要代价)。
- 前一天扫描贪心匹配wa了,现在复习也没时间去找bug。
先这样了
A3.
- 被卡住了
还有些疑问,去学vue写报告了,先这样
------------------------代码分割线------------------------
A1.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int m;
cin >> m;
vector<vector<int>> a(m);
vector<int> vis(50010);
for (auto &v : a)
{
int n;
cin >> n;
while (n--)
{
int x;
cin >> x;
v.push_back(x);
}
}
vector<int> res;
for (int i = m - 1; i >= 0; i--)
{
auto v = a[i];
int f = 0;
for (auto t : v)
{
if (!vis[t] && !f)
{
f = 1;
res.push_back(t);
}
vis[t] = 1;
}
}
if (res.size() - m)
res.assign(1, -1);
reverse(res.begin(), res.end());
for (auto v : res)
cout << v << " ";
cout << endl;
}
A2.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int m;
cin >> m;
vector<vector<int>> a(m);
vector<int> vis(50010);
for (auto &v : a)
{
int n;
cin >> n;
while (n--)
{
int x;
cin >> x;
v.push_back(x);
}
}
vector<int> res;
for (int i = m - 1; i >= 0; i--)
{
auto v = a[i];
int f = 0;
for (auto t : v)
{
if (!vis[t] && !f)
{
f = 1;
res.push_back(t);
}
vis[t] = 1;
}
}
if (res.size() - m)
res.assign(1, -1);
reverse(res.begin(), res.end());
for (auto v : res)
cout << v << " ";
cout << endl;
}
A3.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n;
cin >> n;
int res = ceil(sqrtl(n)) - 1;
cout << res << endl;
}
// void _()
// {
// int n;
// cin >> n;
// int qrt_n = sqrt(n);
// int k = qrt_n / 2 + (qrt_n * qrt_n != n);
// int res = k - 1 << 1 | 1;
// if ((k - 1) * (k - 1) << 2 == n - 1)
// res--;
// if (n == 1)
// res = 0;
// // bug(k);
// cout << res << endl;
// }

浙公网安备 33010602011771号