• zoj 2193 poj 2585 Window Pains


    拓扑排序。

    深刻体会:ACM比赛的精髓之处不在于学了某个算法或数据结构,而在于知道这个知识点但不知道这个问题可以用这个知识去解决!一看题目,根本想不到是拓扑排序。T_T......

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<vector>
    #include<algorithm>
    using namespace std;
    int mapp[50][50]; char s[1000];
    int i, j, k, f;
    vector<int> abc[1000];
    int jz[20][20];
    int c[20];
    int ff[100][100];
    void chushihua()
    {
        jz[1][1] = 1;
        jz[2][1] = 1; jz[2][2] = 1;
        jz[3][2] = 1; jz[3][3] = 1;
        jz[4][3] = 1;
        jz[5][1] = 1; jz[5][4] = 1;
        jz[6][1] = 1; jz[6][2] = 1; jz[6][4] = 1; jz[6][5] = 1;
        jz[7][2] = 1; jz[7][3] = 1; jz[7][5] = 1; jz[7][6] = 1;
        jz[8][3] = 1; jz[8][6] = 1;
        jz[9][4] = 1; jz[9][7] = 1;
        jz[10][4] = 1; jz[10][5] = 1; jz[10][7] = 1; jz[10][8] = 1;
        jz[11][5] = 1; jz[11][6] = 1; jz[11][8] = 1; jz[11][9] = 1;
        jz[12][6] = 1; jz[12][9] = 1;
        jz[13][7] = 1;
        jz[14][7] = 1; jz[14][8] = 1;
        jz[15][8] = 1; jz[15][9] = 1;
        jz[16][9] = 1;
    }
    int main()
    {
        memset(jz, 0, sizeof(jz));
        chushihua();int ge;
        while (~scanf("%s", s))
        {
            for (i = 0; i < 20; i++)abc[i].clear();
            memset(ff, 0, sizeof(ff));
            if (strcmp("ENDOFINPUT", s) == 0) break;
            memset(c, 0, sizeof(c));
            for (i = 1; i <= 4; i++) for (j = 1; j <= 4; j++) scanf("%d", &mapp[i][j]);
            for (i = 1; i <= 4; i++)
            {
                for (j = 1; j <= 4; j++)
                {
                    ge = (i - 1) * 4 + j;
                    for (f = 1; f <= 9; f++)
                    {
                        if (jz[ge][f] == 1 && f != mapp[i][j])
                        {
                            if (ff[mapp[i][j]][f] == 0)
                            {
                                ff[mapp[i][j]][f] = 1;
                                abc[mapp[i][j]].push_back(f);
                                c[f]++;
                            }    
                        }
                    }
                }
            }
            scanf("%s", s); int df, summ = 0;
            while (1)
            {
                df = 0;
                for (i = 1; i <= 9; i++)
                {
                    if (c[i] == 0)
                    {
                        c[i]--;df = 1;summ++;
                        for (j = 0; j < abc[i].size(); j++) c[abc[i][j]]--;
                        break;
                    }
                }
                if (summ == 9){printf("THESE WINDOWS ARE CLEAN
    ");break;}
                if (df == 0){printf("THESE WINDOWS ARE BROKEN
    ");break;}
            }
        }
        return 0;
    }
  • 相关阅读:
    Qt之qInstallMessageHandler(重定向至文件)
    linux下MySQL安装及设置
    Apache2 同源策略解决方案
    BSD和云 – 不可错过的BSD聚会
    Nginx转发地址解决跨域问题
    Nginx下css的链接问题
    nginx 基本操作
    Azure 媒体服务可将优质内容传输至 Apple TV
    支付宝接口
    drf过滤组件
  • 原文地址:https://www.cnblogs.com/zufezzt/p/4477865.html
Copyright © 2020-2023  润新知