Skip to content

Commit 0e9f16b

Browse files
committed
Merge branch 'main' of github.com:tkzzzzzz6/Algorithm_beginner_learning_notes
2 parents 02ff0fc + f7916f7 commit 0e9f16b

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-05-27 08:59:09
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-05-27 10:04:32
6+
*/
7+
#include <iostream>
8+
#include <vector>
9+
#include <algorithm>
10+
#define endl '\n'
11+
using namespace std;
12+
13+
int main() {
14+
ios::sync_with_stdio(0);
15+
cin.tie(0);
16+
cout.tie(0);
17+
18+
int n, L, r, t;
19+
cin >> n >> L >> r >> t;
20+
21+
vector<vector<int>> A(n, vector<int>(n));
22+
for (int i = 0; i < n; ++i)
23+
for (int j = 0; j < n; ++j)
24+
cin >> A[i][j];
25+
26+
vector<vector<long long>> sum(n, vector<long long>(n));
27+
for (int i = 0; i < n; ++i)
28+
for (int j = 0; j < n; ++j) {
29+
sum[i][j] += A[i][j];
30+
if (i > 0) sum[i][j] += sum[i - 1][j];
31+
if (j > 0) sum[i][j] += sum[i][j - 1];
32+
if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1];
33+
}
34+
35+
auto query = [&](int x1, int y1, int x2, int y2) -> long long {
36+
long long res = sum[x2][y2];
37+
if (x1 > 0) res -= sum[x1 - 1][y2];
38+
if (y1 > 0) res -= sum[x2][y1 - 1];
39+
if (x1 > 0 && y1 > 0) res += sum[x1 - 1][y1 - 1];
40+
return res;
41+
};
42+
43+
int ans = 0;
44+
for (int i = 0; i < n; ++i) {
45+
for (int j = 0; j < n; ++j) {
46+
int x1 = max(0, i - r), y1 = max(0, j - r);
47+
int x2 = min(n - 1, i + r), y2 = min(n - 1, j + r);
48+
long long s = query(x1, y1, x2, y2);
49+
int m = (x2 - x1 + 1) * (y2 - y1 + 1);
50+
if (s <= 1LL * t * m) ans++;
51+
}
52+
}
53+
54+
cout << ans << endl;
55+
56+
return 0;
57+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-05-26 18:59:16
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-05-26 19:08:36
6+
*/
7+
#include <iostream>
8+
#include <vector>
9+
10+
using namespace std;
11+
12+
inline int f(int x, int k) {
13+
return ((x * x + k * k) % 8) ^ k;
14+
}
15+
16+
inline int g(int x, int k) {
17+
int a = (x >> 6) & 7;
18+
int b = (x >> 3) & 7;
19+
int c = x & 7;
20+
21+
int na = b;
22+
int nb = c ^ f(b, k);
23+
int nc = a ^ f(c, k);
24+
25+
return na << 6 | nb << 3 | nc;
26+
}
27+
28+
int main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
int n, m;
33+
cin >> n >> m;
34+
vector<int> k(m);
35+
for (int i = 0; i < m; ++i) cin >> k[i];
36+
37+
vector<int> rev(512);
38+
for (int i = 0; i < 512; ++i) {
39+
int x = i;
40+
for (int j = 0; j < m; ++j) {
41+
x = g(x, k[j]);
42+
}
43+
rev[x] = i;
44+
}
45+
46+
for (int i = 0; i < n; ++i) {
47+
int a;
48+
cin >> a;
49+
cout << rev[a];
50+
if (i + 1 < n) cout << ' ';
51+
}
52+
53+
cout << '\n';
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)