intmain(){ cin >> n; for(int i = 0; i < n; i ++) cin >> a[i]; int len = 0; q[0] = -2e9; for(int i = 0; i < n; i ++) { int l = 0, r = len; while(l < r) { int mid = l + r + 1 >> 1; if(q[mid] < a[i]) l = mid; else r = mid - 1; } q[r + 1] = a[i]; len = max(len, r + 1); } cout << len << endl; return0; }
intfun(char a[], char b[]){ int l1 = strlen(a + 1), l2 = strlen(b + 1); int f[N][N]; for(int i = 0; i <= l1; i ++) f[i][0] = i; for(int i = 0; i <= l2; i ++) f[0][i] = i; for(int i = 1; i <= l1; i ++) for(int j = 1; j <= l2; j ++) { f[i][j] = min(f[i - 1][j], f[i][j - 1]) + 1; f[i][j] = min(f[i][j], f[i - 1][j - 1] + (a[i] != b[j])); } return f[l1][l2]; }
intmain(){ cin >> n >> m; for(int i = 1; i <= n; i ++) { scanf("%s", str[i] + 1); } while(m --) { char s[N]; int x; scanf("%s%d", s + 1, &x); int res = 0; for(int i = 1; i <= n; i ++) { if(fun(str[i], s) <= x) res ++; } cout << res << endl; } return0; }