Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <time.h>
- #include <string.h>
- #include <stdio.h>
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <queue>
- using namespace std;
- #define TRACE(x) x
- #define PRINT(x) TRACE(printf(x))
- #define WATCH(x) TRACE(cout << #x << " = " << x << endl;)
- #define rep(i,n) for (int i=0; i<n; i++)
- const int inf =0x3f3f3f3f;
- const double eps = 1e-9;
- char s[30] = "qweryuopsdfghjklzxvbm";
- int w[20];
- void printBm(int x) {
- for (int i=0; i<21; i++)
- if (x&(1<<i)) printf("1");
- else printf("0");
- printf("\n");
- }
- class Teaching {
- public:
- int count( vector <string> words, int K ) {
- for (int i=0; i<words.size(); i++) {
- int bm=0;
- for (int j=0; j<words[i].size(); j++) {
- for (int k=0; s[k]!='\0'; k++)
- if (words[i][j]==s[k])
- bm|=(1<<k);
- }
- w[i]=bm;
- }
- int maxW=0;
- for (int i=0; i<(1<<21); i++)
- if (__builtin_popcount(i)==K-5) {
- int cnt=0;
- for (int j=0; j<words.size(); j++)
- if ((w[j]&i)==w[j]) ++cnt;
- maxW=max(maxW,cnt);
- }
- return maxW;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement