Submission #46595821


Source Code Expand

#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using int64 = long long;
using uint = unsigned int;
using uint64 = unsigned long long;
bool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; }
bool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; }
using namespace std;

int CP(string& a, string& b) {
  int i = 0, j = 0, res = 0;
  while (i < (int)a.length() && j < (int)b.length()) {
    if (a[i] == b[j]) res++;
    else break;
    i++, j++;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  string s0;
  cin >> n >> s0;
  string s0r = s0;
  reverse(s0r.begin(), s0r.end());
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == s0) {
      ans.push_back(i);
      continue;
    }
    int l = CP(s0, s);
    reverse(s.begin(), s.end());
    int r = CP(s0r, s);
    int t = l + r, x = s0.length(), y = s.length();
    debug(l, r, t, x, y);
    if (abs(x - y) <= 1 && t >= x - 1 && t >= y - 1) ans.push_back(i);
  }
  cout << ans.size() << '\n';
  for (int x : ans) cout << x + 1 << ' ';
  cout << '\n';

  return 0;
}

Submission Info

Submission Time
Task C - Error Correction
User xindubawukong
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1207 Byte
Status AC
Exec Time 36 ms
Memory 5228 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 32
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 2 ms 3644 KiB
001.txt AC 3 ms 4944 KiB
002.txt AC 3 ms 4944 KiB
003.txt AC 3 ms 5012 KiB
004.txt AC 3 ms 5012 KiB
005.txt AC 3 ms 5012 KiB
006.txt AC 36 ms 5228 KiB
007.txt AC 22 ms 4112 KiB
008.txt AC 12 ms 3748 KiB
009.txt AC 7 ms 3576 KiB
010.txt AC 5 ms 3740 KiB
011.txt AC 4 ms 3716 KiB
012.txt AC 3 ms 3652 KiB
013.txt AC 2 ms 3568 KiB
014.txt AC 2 ms 3556 KiB
015.txt AC 2 ms 3488 KiB
016.txt AC 2 ms 3560 KiB
017.txt AC 2 ms 3468 KiB
018.txt AC 2 ms 3560 KiB
019.txt AC 2 ms 3492 KiB
020.txt AC 2 ms 3544 KiB
021.txt AC 2 ms 3644 KiB
022.txt AC 2 ms 3636 KiB
023.txt AC 2 ms 3796 KiB
024.txt AC 2 ms 4364 KiB
025.txt AC 3 ms 4980 KiB
026.txt AC 20 ms 4156 KiB
027.txt AC 19 ms 4208 KiB
028.txt AC 18 ms 4108 KiB
example0.txt AC 1 ms 3444 KiB
example1.txt AC 1 ms 3532 KiB
example2.txt AC 1 ms 3460 KiB