10.03总结

注:这个顺序是 T3,T2,T1,T4

我再用\(ifstreamf,ofstream\) 我就抽死自己

我再不先把所有题看一遍,我就抽死自己

顺带一提2023flag

T1

我再用\(ifstreamf,ofstream\) 我就抽死自己

给你一个序列,保证最多只有两个相同数,表示 \(2^{a_i}\),求有几种方法可以构成\(2^{max(a_i)+1}\)
先推一个公式:
\(2^x+2^x=2^x*2=x^{x+1}\)
所以考虑 \(DP\) 每次如果有与后面重复的得 \(dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + 1)\)
然后如果只有两个(应为我会合并,所以可能有三个)直接合并
但是如果有三个我们还要做一次,但是要变成\(dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + max(1, dp[a[x]]));\)
应为不难得出三个在一起可以有三种方法而且,有三个必定有一个是我合成出的,所以要变换公式。

code

赛时(80)

#include <bits/stdc++.h>
using namespace std;

ifstream fin("team.in");
ofstream fout("team.out");

const int Maxn = 1e5 + 5, mod = 998244353;
int n, maxi, cnt, x, sum, a[Maxn];
map<int, int> dp;

int main() {
ios::sync_with_stdio(0);
fin.tie(0), cout.tie(0);
fin >> n;
for (int i = 1; i <= n; i++) {
  fin >> a[i];
}
sort(a + 1, a + 1 + n);
sum = a[n];
cnt = 1;
if (a[n - 1] == sum) {
  cnt = 2;
}

for (x = 2; x <= n && a[x] != a[x - 1]; x++) {
}
if (x > n) {
  cout << 0;//注意看,这个cout叫小帅(应该要fout)痛失20、rank4
  return 0;
}
for (; x <= n; x++) {
  if (a[x] == a[x - 1]) {
    // cout << x << " ";
    dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + 1);
    dp[a[x] + 1] %= mod;
    if (a[x + 1] != a[x]) {
      a[x]++;
      // cout << dp[a[x]] << "\n";
    } else {
      dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + max(1, dp[a[x]]));
      dp[a[x] + 1] %= mod;
      // cout << dp[a[x] + 1] << "\n";
    }
  }
}
fout << dp[sum + 1];
return 0;
}

AC

#include <bits/stdc++.h>
using namespace std;

ifstream fin("team.in");
ofstream fout("team.out");

const int Maxn = 1e5 + 5, mod = 998244353;
int n, maxi, cnt, x, sum, a[Maxn];
map<int, int> dp;

int main() {
  ios::sync_with_stdio(0);
  fin.tie(0), cout.tie(0);
  fin >> n;
  for (int i = 1; i <= n; i++) {
    fin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  sum = a[n];
  cnt = 1;
  if (a[n - 1] == sum) {
    cnt = 2;
  }

  for (x = 2; x <= n && a[x] != a[x - 1]; x++) {
  }
  if (x > n) {
    fout << 0;//就这一个改动哦
    return 0;
  }
  for (; x <= n; x++) {
    if (a[x] == a[x - 1]) {
      // cout << x << " ";
      dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + 1);
      dp[a[x] + 1] %= mod;
      if (a[x + 1] != a[x]) {
        a[x]++;
        // cout << dp[a[x]] << "\n";
      } else {
        dp[a[x] + 1] = max(dp[a[x]], dp[a[x] + 1] + max(1, dp[a[x]]));
        dp[a[x] + 1] %= mod;
        // cout << dp[a[x] + 1] << "\n";
      }
    }
  }
  fout << dp[sum + 1];
  return 0;
  }

T2
一道模拟
按题意模拟即可

code

std(AC)

#include <bits/stdc++.h>
using namespace std;
bool v[262145][2][3][7];

int n, full;
bool die[262145];
int c[3][6], x[3][6];
int s(int st, int p, int x) { return st ^= 1 << (p * n + x); }
bool have(int st, int p, int x) { return (st >> (p * n + x)) & 1; }
int nx(int b, int dir, int p) {
b += dir ? p : -p;
if (b > 2) b -= 3;
if (b < 0) b += 3;
return b;
}
bool legal(int a, int b, int c, int d) { return a == 4 || c == 4 || a == c || b == d; }

bool srch(int st, int dir, int lp, int lx) {
if (!st) return 1;
if (die[st]) return 0;
if (v[st][dir][lp][lx]) return 0;
v[st][dir][lp][lx] = 1;
int col = c[lp][lx], num = x[lp][lx];
int p = nx(lp, dir, 1 + (num == 10)), flag = 0;
for (int i = 0; i < n; ++i)
  if (have(st, p, i)) flag = 1;
while (!flag) {
  p = nx(p, dir, 1);
  for (int i = 0; i < n; ++i)
    if (have(st, p, i)) flag = 1;
}
for (int i = 0; i < n; ++i)
  if (have(st, p, i) && legal(col, num, c[p][i], x[p][i]))
    if (srch(s(st, p, i), dir ^ (x[p][i] == 11), p, i)) return 1;
return 0;
}

char sol() {
scanf("%d", &n);
full = 1 << (3 * n);
--full;
for (int i = 1; i < (1 << n); ++i)
  if (i & (i - 1))
    for (int j = 1; j < (1 << n); ++j) die[i | (j << n)] = die[i | (j << n + n)] = die[(i << n) | j] = die[(i << n) | (j << n + n)] = die[(i << n + n) | j] = die[(i << n + n) | (j << n)] = 1;
for (int i = 0; i < 3; ++i)
  for (int j = 0; j < n; ++j) scanf("%d%d", &c[i][j], &x[i][j]);
memset(v, 0, sizeof(v));
for (int i = 0; i < 2; ++i)
  for (int j = 0; j < n; ++j)
    if (srch(s(full, 0, j), i, 0, j)) return 'Y';
return 'N';
}

int main() {
freopen("uno.in", "r", stdin);
freopen("uno.out", "w", stdout);
int t;
scanf("%d", &t);
while (t--) printf("%c\n", sol());
return 0;
}

T3

我再不先把所有题看一遍,我就抽死自己

给定四个 \(a_i\) 三个 \(b_i\)\(min(a_i)+min(b_i)\)
简单题,求出最小,然后使用splay写出A+Bproblem

code

赛时(AC)

#include <bits/stdc++.h>
using namespace std;

ifstream fin("lunch.in");
ofstream fout("lunch.out");

int a, cnt = 1e9, mini = 1e9;

int main() {
ios::sync_with_stdio(0);
fin.tie(0), cout.tie(0);
for (int i = 1; i <= 4; i++) {
  fin >> a;
  mini = min(a, mini);
}
for (int i = 1; i <= 3; i++) {
  fin >> a;
  cnt = min(a, cnt);
}
fout << cnt + mini;
return 0;
}

什么 T4 哪去了?

啊?今天有 T4 吗?啊哈哈哈哈哈!

(作者已疯)

posted @ 2023-10-04 21:39  mouse_boy  阅读(6)  评论(0编辑  收藏  举报