比赛链接:Here

A - LR Constraints

赛时做这个好迷啊,英文题面解释不清楚,还是看了日语原文才搞懂

AtCoder Regular Contest 124 (A~B) - 图1 个卡牌上有两个 字符 + 数字 组合,L 的右边所有元素 + 1,R 的左边元素 + 1

最后求出现过数字的乘积,同时对 AtCoder Regular Contest 124 (A~B) - 图2 取余

注意点:开 long long!!!,今天牛客也是,没开 ll debug半天,感谢尚佬指出我的错误

  1. const int N = 1010;
  2. bool vis[N];
  3. int cnt[N];
  4. int main() {
  5. cin.tie(nullptr)->sync_with_stdio(false);
  6. int n, k;
  7. cin >> n >> k;
  8. for (int i = 1; i <= k; ++i) {
  9. char c; int x;
  10. cin >> c >> x;
  11. if (c == 'L') {
  12. vis[x] = 1;
  13. for (int j = x + 1; j <= n; ++j)cnt[j] ++;
  14. } else {
  15. vis[x] = 1;
  16. for (int j = 1; j <= x; ++j)cnt[j] ++;
  17. }
  18. }
  19. ll ans = 1;
  20. for (int i = 1; i <= n; ++i) {
  21. if (!vis[i])ans = ans * cnt[i] % 998244353;
  22. }
  23. cout << ans << '\n';
  24. }

B - XOR Matching 2

对于长度为 AtCoder Regular Contest 124 (A~B) - 图3AtCoder Regular Contest 124 (A~B) - 图4 两个序列,请问是否存在某种排序组合使得某个 AtCoder Regular Contest 124 (A~B) - 图5 被称为 Good

Good定义:可以对 AtCoder Regular Contest 124 (A~B) - 图6 重排序使得每一个 AtCoder Regular Contest 124 (A~B) - 图7

AtCoder Regular Contest 124 (A~B) - 图8 固定时,置换 AtCoder Regular Contest 124 (A~B) - 图9 使得 AtCoder Regular Contest 124 (A~B) - 图10 等价于 AtCoder Regular Contest 124 (A~B) - 图11

所以我们可以直接尝试 AtCoder Regular Contest 124 (A~B) - 图12

  • AtCoder Regular Contest 124 (A~B) - 图13#card=math&code=%5Cmathcal%7BO%7D%28N%5E2log%5C%20N%29)
  1. const int N = 2e3 + 10;
  2. int a[N], b[N];
  3. map<int, int> mp, bg;
  4. set<int>v;
  5. int main() {
  6. cin.tie(nullptr)->sync_with_stdio(false);
  7. int n;
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) cin >> a[i];
  10. for (int i = 1; i <= n; ++i) cin >> b[i], bg[b[i]]++;
  11. for (int i = 1; i <= n; ++i) {
  12. int x = a[1] ^ b[i]; mp = bg;
  13. bool f = true;
  14. for (int j = 1; j <= n and f; ++j)if (!mp[x ^ a[j]]) f = false;
  15. if (f) v.insert(x);
  16. }
  17. cout << v.size() << "\n";
  18. for (int x : v)cout << x << "\n";
  19. }