摘要: 这题做了至少5个小时= =,虽然思路一开始就确定了,但是因为一些错误,比如dp公式里的+打成*,状态未初始化等原因调了好久(>_#include #include #include #include using namespace std;#define MAXN 9999#define MAXSI... 阅读全文
posted @ 2014-04-21 23:40 see_why 阅读(289) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <algorithm>#include <cstring>#include <vector>#include <string>#include <map>#include <queue>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifconst int INF = 1 阅读全文
posted @ 2013-05-24 20:52 see_why 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 刚开始用spfa(久闻大名却一次都没用过)过不了,改dijkstra,wa了十几次后,心灰意冷。。1个小时后终于发现是判断起点与终点相同时,直接continue了,导致后面的数据没有完全输入...改正这个问题后spfa的代码也过了,哈哈#include <iostream>#include <algorithm>#include <cstring>#include <vector>#include <string>#include <map>#include <queue>using namespace std 阅读全文
posted @ 2013-05-24 20:51 see_why 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 一次通过,刚学prim的时候做过一道类似的,将每个点之间的距离保存在double型的邻接矩阵里,然后调用prim#include <iostream>#include <algorithm>#include <iomanip>#include <cstring>#include <cmath>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifdou 阅读全文
posted @ 2013-05-23 20:13 see_why 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 实在是太粗心了,floyd算法中把k打成了i,找了20分钟才找到错.... 题目不难,最多用6个人就能联系在一起,等价于任意2点的距离不超过7#include <iostream>#include <algorithm>#include <cstring>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifint graph[110][110],n,m;const int 阅读全文
posted @ 2013-05-23 19:06 see_why 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 思路是用并查集判断连通,然后判断边数+1==点数,就是判断是否为一颗生成树#include <iostream>#include <set>#include <algorithm>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifconst int MAXN = 100010;int p[MAXN],vis[MAXN],maxv,edge,ok;set<int> 阅读全文
posted @ 2013-05-23 15:18 see_why 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 趁热打铁,再做了道欧拉回路,形成欧拉回路的条件1、所有节点的度都是偶数2、所有节点连通#include <iostream>#include <cstring>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifint degree[1010],p[1010];int find(int x){ return x == p[x] ? x : p[x] = find(p[x]);}int 阅读全文
posted @ 2013-05-22 22:03 see_why 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 第一次接触欧拉路,看了大神的解题报告后写出并查集+欧拉回路,先要用并查集判断是否连通,然后再根据每个节点的入度与出度判断是否为欧拉回路或欧拉路如果所有点入度等于出度,则为欧拉回路如果起点的入度比出度小一且终点的入度比出度大一,则为欧拉路#include <iostream>#include <cstring>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifint p[27],vis 阅读全文
posted @ 2013-05-22 20:48 see_why 阅读(122) 评论(0) 推荐(0) 编辑
摘要: [cce_cpp]//网络流,基本是照着书上的代码敲的,还敲错了o(╯□╰)o#include <cstdio>#include <algorithm>#include <queue>#include <cstring>using namespace std;int cap[20][20],flow[20][20],a[20],p[20];const int INF = 1000000;int main(){ int t,n,m,x,y,c,f; scanf("%d",&t); for(int i = 1; i < 阅读全文
posted @ 2013-05-22 14:50 see_why 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> //第一道用Dijkstra解的题#include <cstring>using namespace std;#ifndef ONLINE_JUDGE#include <fstream>ifstream fin("test.txt");#define cin fin#endifint n,m;const int INF = 1000010;int vis[200],dis[200];int graph[200][200];int main(){ ios::sync_with_stdio(false) 阅读全文
posted @ 2013-05-19 13:16 see_why 阅读(143) 评论(0) 推荐(0) 编辑