跳到正文

题解

题解:AT_arc081_c [ARC081E] Don't Be a Subsequence

CS78约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年10月10日
收录
2026年10月11日
更新
2026年11月21日
篇幅
约 2 分钟
获赞
1

版本

  1. v2当前
  2. v1

第一眼看到这道题还想着暴力枚举,一看是“提高”属实给我吓了一跳。想了想,暴力绝对要炸,因为26个字母几个就炸了,26 * 26 * 26都17576了,所以不行。 思路:

1.先看字符串里是不是有26个不同的字母,不够就直接输出少的那个。

2.写个函数遍历一下,like this:

bool allExist(const vector<array<int, 26>>& nxt, int pos) { const int INF = 1e9; for (int c = 0; c < 26; c++) { if (nxt[pos][c] == INF) return false; } return true; }

char minExist(const vector<array<int, 26>>& nxt, int pos) { const int INF = 1e9; for (int c = 0; c < 26; c++) { if (nxt[pos][c] != INF) return char(‘a’ + c); } return ’?’; }

char minMissing(const vector<array<int, 26>>& nxt, int pos) { const int INF = 1e9; for (int c = 0; c < 26; c++) { if (nxt[pos][c] == INF) return char(‘a’ + c); } return ’?’; }

OK呀也是懒的写完整的了,就这样吧,求点赞Q_Q

原文