吃上时代红利了。
估分 60 + [0 ~ 10] + 16 + 0 = [76 ~ 86]
实际 90 + 24 + 40 + 0 = 154
感谢 cch 的 T1,感谢 cch 的 T3,cch 为什么要换 T2 数据。
何以为。何意味。
T1
90 分算不算过了。
我觉得算。
反正我在 VJ 过了。
那就是过了。
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, q, a[1005][1005];
signed main() {
freopen("xor.in", "r", stdin);
freopen("xor.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
while (q--) {
int r, c, l, s; cin >> r >> c >> l >> s;
for (int x = r; x < r + l && x <= n; x++) {
int E = min(n, c + (x - r));
a[x][c] += s;
if (E + 1 <= n) a[x][E + 1] -= s;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
int cur = 0;
for (int j = 1; j <= n; j++) {
cur += a[i][j]; ans ^= cur;
// cout << cur << " ";
}
// cout << "\n";
}
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= n; j++) {
// cout << a[i][j] << " ";
// }
// cout << "\n";
// }
cout << ans;
return 0;
}T2
考虑对于先手来说,每次进行决策,如果他选择集合大小更小的那一侧,那么每次操作集合大小至少减半,只需要 次操作就必定可以使答案为 ,考虑上“两人是轮流操作”的这个因素,所以当 的时候,答案不可能大于 。同理答案也不可能小于 (因为后手可以采取同样的策略),因此答案一定是 。于是只有在的时候才考虑进行搜索,保证了时间复杂度为 。
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e4 + 5, M = 2e5 + 5;
int n, m;
int a[N], b[M], root;
struct Tree {
int sum[N * 30], lc[N * 30], rc[N * 30], tot;
void insert(int& p, int d, int x) {
if (!p) p = ++tot;
if (d > m) {
sum[p] += x; return;
}
insert((x % b[d] ? lc : rc)[p], d + 1, x);
}
int query(int p, int d) {
if (!p) return 0ll;
if (d > m) return sum[p];
int L = query(lc[p], d + 1), R = query(rc[p], d + 1);
return (d & 1) ? min(L, R) : max(L, R);
}
} tree;
signed main() {
cin >> n >> m;
if (m > 28) { cout << 0; return 0; }
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) cin >> b[i];
for (int i = 1; i <= n; i++) tree.insert(root, 1ll, a[i]);
cout << tree.query(root, 1ll) << "\n";
return 0;
}T3
并非 O (n ^ 2)。
没错我就是 O (n ^ 3),但是比 O(n ^ 2) 更快。
#include <bits/stdc++.h>
using namespace std;
const int N = 1e7;
vector<int> G;
bool flag[N + 5];
int n, a[N + 5], minn[N + 5];
bool prime_of(int x) {
if (x <= N) return !flag[x] && x >= 2;
for (int p : G) {
if (p * p > x) break;
if (x % p == 0) return 0;
}
return x >= 2;
}
struct Bing {
vector<int> fu, sz;
Bing(int n) : fu(n), sz(n, 1) {
for (int i = 0; i < n; i++) fu[i] = i;
}
int find(int x) {
if (fu[x] == x) return x;
return fu[x] = find(fu[x]);
}
void update(int x, int y) {
x = find(x); y = find(y);
if (x == y) return;
if (sz[x] < sz[y]) swap(x, y);
fu[y] = x; sz[x] += sz[y];
}
};
int main() {
freopen("connect.in", "r", stdin);
freopen("connect.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
for (int i = 2; i <= N; i++) {
if (!flag[i]) {
G.emplace_back(i); minn[i] = i;
}
for (int p : G) {
if (i * p > N) break;
flag[i * p] = 1; minn[i * p] = p;
if (i % p == 0) break;
}
}
int T; cin >> T; while (T--) {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
vector<vector<int> > Do(n);
map<int, int> mp;
int pid = n;
for (int i = 0; i < n; i++) {
int x = a[i];
while (x > 1) {
int p = minn[x];
Do[i].emplace_back(p);
while (x % p == 0) x /= p;
if (!mp.count(p)) mp[p] = pid++;
}
}
Bing Bing(pid);
for (int i = 0; i < n; i++) {
for (int p : Do[i]) Bing.update(i, mp[p]);
}
vector<pair<int, int> > E;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int g = __gcd(a[i], a[j]);
if (g > 1 && !prime_of(g)) E.emplace_back(i, j);
}
}
vector<vector<int> > S(n);
for (pair<int, int> g : E) {
int u = g.first, v = g.second;
S[u].emplace_back(v); S[v].emplace_back(u);
}
int ans = n;
for (int o = 0; o < n; o++) {
vector<bool> vis(n, 0);
vis[o] = 1; int maxn = 0;
for (int i = 0; i < n; i++) {
if (vis[i]) continue;
queue<int> q; q.push(i);
vis[i] = 1; int cnt = 0;
while (!q.empty()) {
int u = q.front(); q.pop();
cnt++;
for (int v : S[u]) {
if (!vis[v]) {
vis[v] = 1; q.push(v);
}
}
}
maxn = max(maxn, cnt);
}
ans = min(ans, maxn);
}
cout << ans << "\n";
}
return 0;
}T4
出题人我喜欢你。
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
int n, m, k, c[N];
int main() {
freopen("route.in", "r", stdin);
freopen("route.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
cout << "0\n";
for (int i = 0; i < m; i++) {
int q; cin >> q;
cout << "0\n";
}
return 0;
}