zoukankan      html  css  js  c++  java
  • hdu 4451水题

    挺水的题。我的做法是用ans = N*M*K减去不和谐的数目。首先,对每一个paints shoes对,ans -= N,这是没有问题的。这个操作全执行完以后就能记录每个paints跟多少shoes和谐(用paintspair[i]表示)。然后对于每一个clothes paints对,ans -= paintspair[i],这样就避免了重复计数。

    /*
     * hdu4451/win.cpp
     * Created on: 2012-10-29
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    const int MAXM = 1005;
    int N, M, K;
    int paintspair[MAXM];
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        int p, ans, a, b;
        char str1[100], str2[100];
        vector<int> cp;
        while(scanf("%d%d%d", &N, &M, &K) == 3) {
            if(N == 0 && M == 0 && K == 0) {
                break;
            }
            ans = N * M * K;
            cp.clear();
            fill(paintspair, paintspair + MAXM, K);
            scanf("%d", &p);
            while(p--) {
                scanf(" %s %d %s %d", str1, &a, str2, &b);
                if(strcmp(str1, "clothes") == 0) {
                    cp.push_back(b);
                }else {
                    paintspair[a]--;
                    ans -= N;
                }
            }
            for(int i = 0, len = cp.size(); i < len; i++) {
                ans -= paintspair[cp[i]];
            }
            printf("%d\n", ans);
        }
        return 0;
    }
  • 相关阅读:
    Django-haystack对接elasticsearch
    Django http 和 https 官网解答
    -bash: nohup: command not found
    Mysql 10060登录异常解决方法
    ssh
    sed grep awk用法
    grep用法
    shell 随笔
    列表生成式
    css
  • 原文地址:https://www.cnblogs.com/moonbay/p/2745232.html
Copyright © 2011-2022 走看看