Skip to content

Commit f67fce5

Browse files
committed
FDUPC 2025 Preliminary
1 parent 978b1e8 commit f67fce5

File tree

6 files changed

+360
-0
lines changed

6 files changed

+360
-0
lines changed

FDUOJ/FDUPC_2025/FDUPC25P-A.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @file FDUPC25P-A.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
const string way = "ESWN";
20+
21+
void solve(void) {
22+
char c;
23+
int q;
24+
cin >> c >> q;
25+
26+
int x = 0;
27+
while (way[x] != c) x++;
28+
29+
while (q--) {
30+
cin >> c;
31+
if (c == 'L') x = (x + 3) & 3;
32+
if (c == 'R') x = (x + 1) & 3;
33+
if (c == 'B') x = (x + 2) & 3;
34+
cout << way[x] << ' ';
35+
}
36+
37+
cout << endl;
38+
39+
return;
40+
}
41+
42+
bool mem2;
43+
44+
int main() {
45+
ios::sync_with_stdio(false), cin.tie(nullptr);
46+
#ifdef LOCAL
47+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
48+
#endif
49+
50+
int _ = 1;
51+
while (_--) solve();
52+
53+
#ifdef LOCAL
54+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
55+
#endif
56+
return 0;
57+
}

FDUOJ/FDUPC_2025/FDUPC25P-B.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @file FDUPC25P-B.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
void solve(void) {
20+
string s, t;
21+
cin >> s;
22+
for (size_t i = 0; i < s.size(); i++) {
23+
t.push_back(s[i]);
24+
if (i >= 10 && s.substr(i - 10, 11) == "TuLingJiang") t.push_back('~');
25+
}
26+
27+
cout << t << endl;
28+
29+
return;
30+
}
31+
32+
bool mem2;
33+
34+
int main() {
35+
ios::sync_with_stdio(false), cin.tie(nullptr);
36+
#ifdef LOCAL
37+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
38+
#endif
39+
40+
int _ = 1;
41+
while (_--) solve();
42+
43+
#ifdef LOCAL
44+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
45+
#endif
46+
return 0;
47+
}

FDUOJ/FDUPC_2025/FDUPC25P-C.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @file FDUPC25P-C.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
#define maxn 100005
20+
21+
int a[maxn], x[maxn];
22+
23+
void solve(void) {
24+
int n;
25+
cin >> n;
26+
for (int i = 1, u, v; i <= n; i++) cin >> u >> v, a[i] = v - u;
27+
for (int i = 1; i <= n; i++) cin >> x[i];
28+
29+
sort(a + 1, a + n + 1), sort(x + 1, x + n + 1);
30+
31+
int64_t ans = 0;
32+
for (int i = 1; i <= n; i++) ans += abs(a[i] - x[i]);
33+
cout << ans << endl;
34+
35+
return;
36+
}
37+
38+
bool mem2;
39+
40+
int main() {
41+
ios::sync_with_stdio(false), cin.tie(nullptr);
42+
#ifdef LOCAL
43+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
44+
#endif
45+
46+
int _ = 1;
47+
while (_--) solve();
48+
49+
#ifdef LOCAL
50+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
51+
#endif
52+
return 0;
53+
}

FDUOJ/FDUPC_2025/FDUPC25P-D.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @file FDUPC25P-D.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
bool mem1;
14+
15+
int query(int op) {
16+
cout << "? " << op << endl;
17+
int t;
18+
cin >> t;
19+
return t;
20+
}
21+
22+
void solve(void) {
23+
int x = 1;
24+
while (query(0)) x++;
25+
int n = 1;
26+
while (query(1)) n++;
27+
for (int i = n; i > x; i--) query(0);
28+
cout << "! " << n << ' ' << x << endl;
29+
return;
30+
}
31+
32+
bool mem2;
33+
34+
int main() {
35+
ios::sync_with_stdio(false), cin.tie(nullptr);
36+
#ifdef LOCAL
37+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
38+
#endif
39+
40+
int _ = 1;
41+
while (_--) solve();
42+
43+
#ifdef LOCAL
44+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
45+
#endif
46+
return 0;
47+
}

FDUOJ/FDUPC_2025/FDUPC25P-E.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @file FDUPC25P-E.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
#define maxn 305
20+
21+
using pii = pair<int, int>;
22+
23+
const int dw[4][2] = {{+1, 0}, {-1, 0}, {0, +1}, {0, -1}};
24+
25+
string s[maxn];
26+
int dist[maxn][maxn];
27+
28+
void solve(void) {
29+
int n, m;
30+
cin >> n >> m;
31+
for (int i = 1; i <= n; i++) cin >> s[i], s[i] = ' ' + s[i] + ' ';
32+
33+
for (int i = 1; i <= n; i++)
34+
for (int j = 1; j <= n; j++) dist[i][j] = INT_MAX;
35+
36+
int q;
37+
cin >> q;
38+
while (q--) {
39+
int op, x, y;
40+
cin >> op >> x >> y;
41+
assert(s[x][y] == '.');
42+
if (op == 1) {
43+
queue<pii> que;
44+
dist[x][y] = 0, que.emplace(x, y);
45+
while (!que.empty()) {
46+
auto [x, y] = que.front();
47+
que.pop();
48+
for (int t = 0; t < 4; t++) {
49+
int tx = x + dw[t][0], ty = y + dw[t][1];
50+
if (tx < 1 || tx > n || ty < 1 || ty > n || s[tx][ty] == '#' || dist[tx][ty] <= dist[x][y] + 1) continue;
51+
dist[tx][ty] = dist[x][y] + 1, que.emplace(tx, ty);
52+
}
53+
}
54+
} else
55+
cout << (dist[x][y] == INT_MAX ? -1 : dist[x][y]) << endl;
56+
}
57+
58+
return;
59+
}
60+
61+
bool mem2;
62+
63+
int main() {
64+
ios::sync_with_stdio(false), cin.tie(nullptr);
65+
#ifdef LOCAL
66+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
67+
#endif
68+
69+
int _ = 1;
70+
while (_--) solve();
71+
72+
#ifdef LOCAL
73+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
74+
#endif
75+
return 0;
76+
}

FDUOJ/FDUPC_2025/FDUPC25P-F.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* @file FDUPC25P-F.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2025-11-27
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
#define maxn 100000
20+
21+
vector<int> Cs[maxn];
22+
23+
void solve(void) {
24+
int n, m, l, r;
25+
cin >> n >> m >> l >> r;
26+
27+
int lim = 0;
28+
while (lim <= n && (int64_t)lim * (lim - 1) / 2 <= r) lim++;
29+
30+
int ans = 0;
31+
32+
// C(n, 0)
33+
if (l == 1) {
34+
if (lim <= 0) ans--;
35+
ans += max(0, n - lim + 1);
36+
ans += max(0, min(n, m) - lim + 1);
37+
}
38+
39+
// C(n, 1)
40+
int xl = max(lim, l), xr = min(n, r);
41+
if (lim <= 2 && m >= 1) ans--;
42+
if (m >= 1) ans += max(0, xr - xl + 1);
43+
ans += max(0, min(xr, m + 1) - xl + 1);
44+
45+
for (int i = 1; i < lim; i++) {
46+
int xl = lower_bound(Cs[i].begin(), Cs[i].end(), l) - Cs[i].begin(),
47+
xr = upper_bound(Cs[i].begin(), Cs[i].end(), r) - Cs[i].begin() - 1;
48+
ans += max(0, min(xr, m) - xl + 1);
49+
if (!(i & 1) && xr * 2 == i) xr--;
50+
tie(xl, xr) = make_pair(i - xr, i - xl);
51+
ans += max(0, min(xr, m) - xl + 1);
52+
}
53+
54+
cout << ans << endl;
55+
56+
return;
57+
}
58+
59+
bool mem2;
60+
61+
int main() {
62+
ios::sync_with_stdio(false), cin.tie(nullptr);
63+
#ifdef LOCAL
64+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
65+
#endif
66+
67+
for (int i = 1; i < maxn; i++) {
68+
int64_t val = 1;
69+
for (int j = 0; j <= i - j && val <= 1e9; val = val * (i - j) / (j + 1), j++) Cs[i].push_back(val);
70+
}
71+
72+
int _ = 1;
73+
cin >> _;
74+
while (_--) solve();
75+
76+
#ifdef LOCAL
77+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
78+
#endif
79+
return 0;
80+
}

0 commit comments

Comments
 (0)