1 条题解

  • 0
    @ 2023-11-9 18:20:49
    #include <bits/stdc++.h>
    using namespace std;
    char t[33], s[2020];
    int n, k, ans;
    #define ull unsigned long long
    set<ull> st;
    
    int main() {
    	scanf("%s%s%d", s, t, &k);
    	n = strlen(s);
    	for (int i = 0; i < n; i++) {
    		ull h = 0;
    		for (int j = i, c = 0; j < n; j++) {
    			if (t[s[j] - 'a'] == '0')
    				c++;
    			if (c > k)
    				break;
    			h = h * 31 + s[j] - 'a' + 1;
    			st.insert(h);
    		}
    	}
    	printf("%d\n", st.size());
    	return 0;
    }
    
    • 1

    信息

    ID
    1
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    10
    已通过
    3
    上传者