当前位置: 首页 > news >正文

服务器网站打开慢/站长之家app

服务器网站打开慢,站长之家app,做美股的数据网站,如何做网站管理Bus Routes Advanced Calculator Autopilot System Immortality of Frog Land of Farms 给出 n*m的矩形,数字 0--9表示 古代的农场,古代农场里的羊不打架, (这里练的时候,没有理解对题意,样例都推不出来&am…

Bus Routes

 

Advanced Calculator

 

Autopilot System

 

Immortality of Frog

 

Land of Farms

给出 n*m的矩形,数字 0--9表示 古代的农场,古代农场里的羊不打架,

(这里练的时候,没有理解对题意,样例都推不出来,,练习的时候,以为是,古代的羊都不打架,所以古代农场都可以相邻,但是实际是,只能是联通块里面的羊不打架)

如果选择了古代农场,整个联通的这块古代农场都要被选

"."表示空地

现在需要新修农场,农场与农场之间不能相邻

问最多能够得到多少个农场

先将不冲突的农场之间连边,然后求出最大团,最大团里面的农场就满足两两之间都不冲突,而且数目是最多的

具体建图是

先初始化 100*100的图的矩阵

先给每个点编号,每个古代农场的联通块编号

然后编好号之后,扫一遍每一个点的上下左右四个方向,如果编号不同,就把这条边否决掉

然后跑最大团

另外比如样例

原图

. . 3 .

023 .

.2 1 1

编号矩阵是

1 2 3 4

5 6 3 7

8 6 9 9

像 3 和 3之间的边置为0,置为 1都可以(因为相当于是连向自己的边)

  1 #include<cstdio>
  2 #include<cstring>
  3 #include<iostream>
  4 #include<algorithm>
  5 #include<vector>
  6 using namespace std;
  7 
  8 const int maxn = 105;
  9 char G[maxn][maxn];
 10 int g[maxn][maxn];//tu
 11 int p[maxn][maxn];//tu de bian hao
 12 int n,m;
 13 int vis[maxn][maxn];
 14 int dx[4] = {1,-1,0,0};
 15 int dy[4] = {0,0,1,-1};
 16 int Clique[maxn],New[maxn][maxn];
 17 int ans,N;
 18 int used[maxn];
 19 
 20 int number(char c){
 21     return c >= '0' && c <= '9';
 22 }
 23 
 24 int DFS(int T, int cnt)
 25 {
 26     if(T == 0)
 27     {
 28         if(ans < cnt)
 29         {
 30             ans = cnt;
 31             return 1;
 32         }
 33         return 0;
 34     }
 35     for(int i = 0; i < T; i++)
 36     {
 37         if(T - i + cnt <= ans) return 0;
 38         int u = New[cnt][i];
 39         if(Clique[u] + cnt <= ans) return 0;
 40         int num = 0;
 41         for(int j = i+1; j < T; j++)
 42             if(g[u][New[cnt][j]] == 1)
 43                 New[cnt+1][num++] = New[cnt][j];
 44         used[cnt+1] = u;
 45         if(DFS(num, cnt+1)) return 1;
 46     }
 47     return 0;
 48 }
 49 int MaxClique()
 50 {
 51     memset(Clique, 0, sizeof(Clique));
 52     ans = 0;
 53     for(int i = N; i >= 1; i--)
 54     {
 55         used[1] = i; int Size = 0;
 56         for(int j = i+1; j <= N; j++)
 57             if(g[i][j] == 1)
 58                 New[1][Size++] = j;
 59         DFS(Size, 1);
 60         Clique[i] = ans;
 61     }
 62     return ans;
 63 }
 64 
 65 void find_cc(int x,int y,int key){
 66     p[x][y] = key;
 67     for(int i = 0;i < 4;i++){
 68         int xx = x+dx[i];
 69         int yy = y+dy[i];
 70         if(xx <= 0 || xx > n || yy <= 0 || yy > m || p[xx][yy]) continue;
 71         if(G[xx][yy] == '.') continue;
 72         if(G[xx][yy] == G[x][y]) find_cc(xx,yy,key);
 73     }
 74 }
 75 
 76 void build(){
 77     memset(vis,0,sizeof(vis));
 78     memset(p,0,sizeof(p));
 79     int cnt = 0;
 80     for(int i = 1;i <= n;i++){
 81             for(int j = 1;j <= m;j++){
 82                     if(G[i][j] == '.' && !p[i][j]) p[i][j] = ++cnt;
 83                     if(G[i][j] >= '0' && G[i][j] <= '9'&& !p[i][j]){
 84                         find_cc(i,j,++cnt);
 85                     }
 86                 }
 87     }
 88    /* for(int i = 1;i <= n;i++){
 89         for(int j = 1;j <= m;j++) printf("%d ",p[i][j]);
 90         printf("\n");
 91     }*/
 92     for(int i = 1;i <= maxn;i++)
 93         for(int j = 1;j <= maxn;j++) g[i][j] = 1;
 94     for(int i = 1;i <= n;i++){
 95         for(int j = 1;j <= m;j++){
 96             for(int k = 0;k < 4;k++){
 97                 int x = i+dx[k];
 98                 int y = j+dy[k];
 99                 if(x <= 0 || x > n || y <= 0 || y > m) continue;
100                 int u = p[i][j];
101                 int v = p[x][y];
102                 if(u != v) g[u][v] = g[v][u] = 0;
103             }
104         }
105     }
106    /* for(int i = 1;i <= cnt;i++){
107         for(int j = 1;j <= cnt;j++) printf("g[%d][%d] = %d\n",i,j,g[i][j]);
108     }*/
109     N = cnt;
110 }
111 
112 int main(){
113     int T;
114    // freopen("in.txt","r",stdin);
115     //freopen("outtt.txt","w",stdout);
116 
117     scanf("%d",&T);
118     int kase = 0;
119     while(T--){
120         scanf("%d %d",&n,&m);
121         for(int i = 1;i <= n;i++){
122             scanf("%s",G[i]+1);
123         }
124         build();
125         //printf("N = %d\n",N);
126         printf("Case #%d: %d\n",++kase,MaxClique());
127     }
128     return 0;
129 }
View Code

 

 

 

 

Matching Compressed String

 

Alice's Classified Message

 

Frog and String

 

The Shields

 

Kingdom of Tree

 

转载于:https://www.cnblogs.com/wuyuewoniu/p/4970378.html

http://www.jmfq.cn/news/4830247.html

相关文章:

  • 门户型网站建设方案/怎么样建网站
  • 机械公司网站源码/今日国际军事新闻头条
  • 做网赚类网站违法吗/seo外包方法
  • 高端网站开发找哪家好/西安网站制作价格
  • python做网站教程/百度广告推广怎么做
  • 医程通 网站做的太/百度推广一天烧多少钱
  • 做网站价格 网络推广托管服务/好推建站
  • 建站abc平台/站长之家是什么
  • 网站建设好不好/百度贴吧官网入口
  • wordpress访问多站点/wifi优化大师下载
  • dede鲜花网站模板下载/google官网进入
  • 常用网站建设技术/高端建站
  • 怎么修改网站上的内容/百度投广告怎么收费
  • 网页制作报价/移动建站优化
  • 陕西做网站的公司在哪/网推项目
  • Wordpress付费主题排名/手机seo百度点击软件
  • 做网站用的什么编程语言/陕西百度推广的代理商
  • 怎么做公司招聘网站/天津抖音seo
  • wordpress弹窗登录注册插件/seo站长论坛
  • 地方门户信息网站建设方案/推广注册app拿佣金平台
  • 做网站的调研报告/市场营销毕业论文5000字
  • 北京网站建设排行/培训seo哪家学校好
  • 搜索网站建设推广优化/专业的seo外包公司
  • 营销型网站模板下载/网站更换服务器对seo的影响
  • 公司网站需要在公安局备案吗/哈尔滨百度公司地址
  • 淘宝做网站建设靠谱吗/营销推广主要包括
  • 做营销网站哪家好/万能搜索引擎网站
  • 西乡做网站价格/线上营销平台有哪些
  • 百度权重怎么提高/嘉兴关键词优化报价
  • 洛阳网站推广怎么做/社群营销的十大案例