07 2012 档案

摘要:本题目的dfs原理不难,个人认为难点式路径的记录,刚开始定义了很大的数组,提交的时候超出了内存的限制,后来在网上发现有的人用了栈存储,纠结了半天终于搞出来啦。#include <stdio.h> #include <string.h> int flag; int st[7]; int head; int in[6]; int digit; int digit2; int num1,max; int de; void dfs(int cur,int sum) { if(cur>=digit2) { if(sum>max) { max=sum; flag=1; 阅读全文
posted @ 2012-07-02 11:41 LJ_COME!!!!! 阅读(127) 评论(0) 推荐(0)
摘要:此题的本质问题就是对无向图的着色,使颜色使用最少的问题#include <stdio.h>#define maxn 27typedef struct Node{ int next[maxn]; int tot;}node;int main(){ int n; while(scanf("%d",&n)&&n!=0) { getchar();//吸收回车 node map[maxn]; int i,j,k; for(i=0;i<n;i++)//建图 { map[i].tot=0; getchar();//吸收每行的首字母,因为是字典序输 阅读全文
posted @ 2012-07-01 11:30 LJ_COME!!!!! 阅读(109) 评论(0) 推荐(0)