bool IsURL(wstring const &str) { if(str.find(TEXT(" "), 0) != wstring::npos) { return false; } wstring upr(UpperCase(str)); if(upr.compare(0, 7, TEXT("HTTP://")) == 0 || upr.compare(0, 8, TEXT("HTTPS://")) == 0) { return true; } WCHAR **tld = gTopLevelDomains; while(*tld != nullptr) { if(upr.find(*tld, 0) != wstring::npos) { return true; } ++tld; } return false; }
int get() { static char s[1024]; int i; scanf(" %s", s); upr(s); for (i = 0; i < n; i++) if (strcmp(names[i], s) == 0) break; return i; }
void solve() { static int a[1024], ptab[32][32], m, p; int i, j, k; scanf("%d %d %d", &n, &p, &m); for (i = 0; i < n; i++) { scanf(" %s", names[i]); upr(names[i]); } qsort(names, n, sizeof(names[0]), &cmp); memset(ptab, 0, sizeof(ptab)); for (i = 0; i < p; i++) { j = get(); k = get(); ptab[j][k] = ptab[k][j] = 1; } for (k = 0, a[0] = -1; k >= 0;) { if (k == m) { printf("%s", names[a[0]]); for (i = 1; i < m; i++) printf(" %s", names[a[i]]); printf("\n"); k--; continue; } a[k]++; if (a[k] >= n) { k--; continue; } for (i = 0; i < k; i++) if (ptab[a[i]][a[k]]) break; if (i >= k) { a[k + 1] = a[k]; k++; } } }
map<string,string> GetReady::mapPromoter(string promoters_address) { map<string,string> dictPromoter; ifstream data(promoters_address.c_str()); char ch; for(;data.get(ch);) { while(ch=='#') { string noUse; getline(data,noUse); data.get(ch); } string line; char nameLine[20]; getline(data,line); int j,i; for(j=0;line[j]!=' ';j++){} j++; for(i=0;line[j]!=' ';i++) { nameLine[i]=line[j]; j++; } nameLine[i]='\0'; lwr(nameLine); j++; for(;line[j]!=' ';j++){} j++; for(;line[j]!=' ';j++){} j++; for(;line[j]!=' ';j++){} j++; char tempSequence[100]; for(i=0;line[j]!=' ';i++) { tempSequence[i]=line[j]; j++; } tempSequence[i]='\0'; upr(tempSequence); string name=nameLine; dictPromoter[name]=tempSequence; } return dictPromoter; }
wstring UpperCase(wstring const &str) { wstring upr(str); std::transform(upr.begin(), upr.end(), upr.begin(), ::toupper); return upr; }