#include #include #include #include #include using namespace std; const int LT = 100000; const int LQ = 1000; bool pstrcmp(const char *p, const char *q) { return strncmp(p, q, 1000) < 0; } int main(void) { ifstream cin("english.in"); int nCase = 0; string line; while(getline(cin, line)) { string text = ""; while(getline(cin, line), line != "%%%%%") text += line + " "; const char *ptext = text.c_str(); static const char *p[LT+1]; int n = text.length(); for(int i = 0; i < n; i++) p[i] = ptext + i; sort(p, p + n, pstrcmp); if(nCase > 0) cout << endl; cout << "Case " << (++nCase) << ":" << endl; while(getline(cin, line), line != "%%%%%") { const char **plo = lower_bound(p, p + n, line.c_str(), pstrcmp); (*(line.end() - 1))++; const char **phi = lower_bound(p, p + n, line.c_str(), pstrcmp); cout << phi - plo << endl; } // discard empty line getline(cin, line); } }