예제 #1
0
파일: analyzer.cpp 프로젝트: M4573R/pc-code
void read_text()
{
    HM hm;

    Zero(loc);
    nnodes = 0;
    nwords = uwords = 0;

    while (true) {
        rr.next_line(line, len);
        if (strcmp("END", line) == 0) break;

        int i = 0;
        while (true) {
            while (i < len && ! islower(line[i])) ++i;
            if (i >= len) break;

            char *tok = &line[i];
            while (islower(line[i])) ++i;
            line[i] = 0;

            int id = hm.add(HM::Key(tok), uwords);
            if (id == uwords) ++uwords;
            ++nwords;

            loc[id].append(nwords);
        }
    }
}
예제 #2
0
int main()
{
    Reader rr;
    while (true) {
        n = rr.next_u32();
        if (n == 0) break;

        HM hm;
        int pop = 0;
        int ans = 0;
        while (n--) {
            for (int i = 0; i < 5; ++i)
                ns[i] = rr.next_u32();

            HM::Key k(ns);
            int p = hm.add(k);
            if (p > pop)
                ans = pop = p;
            else if (p == pop)
                ans += p;
        }
        printf("%d\n", ans);
    }

    return 0;
}
예제 #3
0
파일: baker.cpp 프로젝트: asifcse10/pc-code
int main()
{
    Reader rr;
    int t = rr.next_u32();

    while (t--) {
        rr.skip_line();
        rr.next_real_line(str, len);
        for (int i = 0; i < len; ++i)
            str[i] = toupper(str[i]);

        title = string(str);
        m = rr.next_u32();
        n = rr.next_u32();
        b = rr.next_u32();

        HM hm;

        while (m--) {
            rr.next(str);
            int c = rr.next_u32();
            Datum d(str, c);
            hm.add(d);
        }

        RV recipes;
        while (n--) {
            rr.skip_line();
            rr.next_real_line(str, len);
            string recipe = string(str);

            int n_ing = rr.next_u32();
            int recipe_cost = 0;

            while (n_ing--) {
                rr.next(str);
                int k = rr.next_u32();

                recipe_cost += hm.get(string(str)) * k;
            }
            if (recipe_cost <= b)
                recipes.push_back(Recipe(recipe, recipe_cost));
        }

        printf("%s\n", title.c_str());
        if (recipes.size() > 0) {
            sort(recipes.begin(), recipes.end());
            cFor (RV, r, recipes)
                printf("%s\n", (r->name).c_str());
        }
        else
            puts("Too expensive!");
        putchar('\n');
    }

    return 0;
}
예제 #4
0
int solve()
{
    sort(hs.begin(), hs.end());
    Zero(hpl);

    int ans = -1;

    HM::Datum d(hpl, 0);

    HM hm;
    hm.add(d, ans);

    int max_hurdles = 0;

    for (int i = 0, I = hs.size(); i < I; ++i) {
        int curr_mark = hs[i].mark;

        d.mark = curr_mark;
        hm.add(d, ans);

        for (int j = i; j < I && hs[j].mark == curr_mark; ++j) {
            i = j;
            int lane = hs[j].lane;
            ++hpl[lane];
            if (hpl[lane] > max_hurdles)
                max_hurdles = hpl[lane];
        }

        ++d.mark;
        for (int j = 0; j < K; ++j)
            d.lanes[j] = max_hurdles - hpl[j];

        hm.add(d, ans);
    }

    d.mark = L;
    hm.add(d, ans);

    return ans;
}
예제 #5
0
파일: easy.cpp 프로젝트: M4573R/pc-code
int main()
{
    Reader rr;
    while (rr.has_next()) {
        n = rr.next_u32();
        m = rr.next_u32();

        HM hm;

        for (int i = 1; i <= n; ++i) {
            int v = rr.next_u32();
            hm.add(v, i);
        }
        while (m--) {
            int k = rr.next_u32();
            int v = rr.next_u32();
            printf("%d\n", hm.get(v, k));
        }
    }

    return 0;
}
예제 #6
0
int main(void){

	HM *h = HM_HM();
	printf("Adding: %s\n","one");	
	h->put(h,"one",3,1);
	printf("Size: %d\n",h->size);
	printf("Adding: %s\n","two");
	h->put(h,"two",3,2);
	printf("Size: %d\n",h->size);
	
	printf("Get: %s Result: %d \n","two",h->get(h,"two",3));
	printf("Get: %s Result: %d \n","one",h->get(h,"one",3));
	
	printf("Exists: %s  %s\n","two",h->exists(h,"two",3)?"YES":"NO");
	printf("Exists: %s  %s\n","zero",h->exists(h,"zero",4)?"YES":"NO");
	
	
	
	return 0;
}