Codeforces Round 921 (Div. 2)

比赛链接

A

[Codeforces 1925A] We Got Everything Covered!.cpp >folded
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
int read(int x = 0, int f = 0, char ch = getchar())
{
while (ch < 48 or 57 < ch) f = ch == 45, ch = getchar();
while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar();
return f ? -x : x;
}
const int N = 1e6 + 5;
int n, a[N];

void solve()
{
int n = read(), k = read();
for (int i = 0, j = 1; j <= n * k; j++, i = (i + 1) % k)
printf("%c", 'a' + i);
puts("");
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("A.in", "r", stdin);
#endif
for (int T = read(); T--; solve());
return 0;
}

B

[Codeforces 1925B] A Balanced Problemset?.cpp >folded
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
// #define int long long
int read(int x = 0, int f = 0, char ch = getchar())
{
while (ch < 48 or 57 < ch) f = ch == 45, ch = getchar();
while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar();
return f ? -x : x;
}
const int N = 3e5 + 5;
int n, a[N];
int b[N];

void solve()
{
int x = read(), n = read(), ans = 1;
for (int i = 1; i * i <= x; i++)
if (x % i == 0)
{
if (n <= x / i) ans = std::max(ans, i);
if (n <= i) ans = std::max(ans, x / i);
}
std::cout << ans << '\n';
}

signed main()
{
#ifndef ONLINE_JUDGE
freopen("B.in", "r", stdin);
#endif
for (int T = read(); T--; solve());
return 0;
}

C

在答案的构造上有一些小细节容易被坑

前面的不能乱填

[Codeforces 1925C] Did We Get Everything Covered?.cpp >folded
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
int read(int x = 0, int f = 0, char ch = getchar())
{
while (ch < 48 or 57 < ch) f = ch == 45, ch = getchar();
while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar();
return f ? -x : x;
}
bool buk[26];
void solve()
{
int n = read(), k = read(), m = read();
std::string s, ans;
std::cin >> s;
int cnt = 0, tot = 0;
memset(buk, 0, sizeof buk);
for (auto ch : s)
{
if (ans.size() == n) break;
cnt += !buk[ch - 'a'], buk[ch - 'a'] = 1;
if (cnt == k) cnt = 0, ans += ch, memset(buk, 0, sizeof buk);
}
if (ans.size() == n) puts("YES");
else
{
puts("NO");
for (int i = 0; i < k; i++)
if (!buk[i])
while (ans.size() < n)
ans += char(i + 'a');
std::cout << ans << '\n';
}
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("C.in", "r", stdin);
#endif
for (int T = read(); T--; solve());
return 0;
}

D

出题人出的什么瘠薄题面

best sol

[Codeforces 1925D] Good Trip.cpp >folded
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define int long long
int read(int x = 0, int f = 0, char ch = getchar())
{
while (ch < 48 or 57 < ch) f = ch == 45, ch = getchar();
while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar();
return f ? -x : x;
}
const int P = 1e9 + 7;

int pow(int x, int k, int res = 1)
{
for (x = (x + P) % P; k; k >>= 1, x = x * x % P)
if (k & 1) res = res * x % P;
return res;
}

void solve()
{
int n = read(), m = read(), k = read();
int sum = 0, ans = 0;
for (int i = 1; i <= m; i++)
read(), read(), sum = (sum + read()) % P;
int all = pow(n * (n - 1) / 2, P - 2), p = m * all % P;
for (int i = 1; i <= k; i++)
ans = (ans + sum * all) % P, sum = (sum + p) % P;
std::cout << ans << '\n';
}

signed main()
{
#ifndef ONLINE_JUDGE
freopen("D.in", "r", stdin);
#endif
for (int T = read(); T--; solve());
return 0;
}

E

>folded
1

Author

TosakaUCW

Posted on

2024-01-30

Updated on

2024-02-01

Licensed under

Comments