ZOJ 3630 Information
这题的意思是有一个城市可以发送和接收信息 把城市看成点 给m条边 单向图 问:删去一个点后 最大的一个强连通中的个数最小是多少。
我用的暴力做法 考虑到n<=100 暴力遍历
#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;#define MAXN 110int sum[MAXN],stack[MAXN],dfn[MAXN],low[MAXN],times,top,m,n;bool instack[MAXN];int scan;vector <int> e[MAXN];void init(){ memset(instack,0,sizeof(instack)); memset(dfn,0,sizeof(dfn)); memset(low,0,sizeof(low)); times=top=sum[0] ...
hdu 2767 Proving Equivalences 强连通 缩点 求度
本题题意是 给你n个点m条边 要求如果需要将这个图变成强连通最少需要多少条边
我的做法是强连通分量缩点+求度 取 max(出度为0的数量,入度为0的数量)的值就是
//First Edit Time:2014-05-04 20:55//Last Edit Time: 2014-05-04 21:38#include <iostream>#include <cstdio>#include <cstring>#include <vector>using namespace std;//给n个点m条边 求最少加几条边使之成为强连通#define MAXN 20010vector <int> e[MAXN];bool instack[MAXN];int dfn[MAXN],low[MAXN],top,times;int stack[MAXN];int n,m;int sum[MAXN];int tran[MAXN];int chu[MAXN];int ru[MAXN];void tarjan(int u){ ...
2.8.5 完美洗牌术 Stack 'em Up
思路&题解
PC/UVA 110205/10205
水题。模拟
//author: CHC//First Edit Time: 2014-01-22 13:06//Last Edit Time: 2014-01-22 13:22//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;int type[120][60],n;char value[13][10]={ "2","3","4","5","6","7","8","9","10","Jack","Queen","King&q ...
2.8.4 解密 Crypt Kicker
思路&题解
PC/UVA 110204/843
本题。DFS。但是由于过多的使用set。导致TLE。。话说。我第一次在挑战编程的那个网站上看到有这个状态。。
//author: CHC//First Edit Time: 2014-01-22 11:17//Last Edit Time: 2014-01-22 12:14//Filename:3.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <set>#include <sstream>#include <algorithm>using namespace std;int n,ok;int s_len[20];char s_word[20][1010][20];char m_word[1010][20];int m_len[1010];char ha[20][1010],v[256];char vis[256];char ...
2.8.3 罢工 Hartals
思路&题解
PC/UVA 110203/10050
裸的bfs
//author: CHC//First Edit Time: 2014-01-17 12:12//Last Edit Time: 2014-01-17 12:36//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;struct po{ int cur;//第几天 int day;//0~6代表星期天到星期六 int jg;};int ha[4000];queue <po> q;int n,p;int bfs(){ po now; int num=0; while(!q.empty()){ now=q.front(); q.pop(); ...
2.8.2 扑克牌型 Poker Hands
思路&题解
PC/UVA 110202/10315
本题。按顺序比较牌型。
//author: CHC//First Edit Time: 2014-01-16 14:29//Last Edit Time: 2014-01-16 21:09//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;char tran[]={ '0','2','3','4','5','6','7','8','9','T','J','Q','K','A' ...
2.8.1 快乐的跳跃着 Jolly Jumpers
思路&题解
PC/UVA 110201/10038
水题。
//author: CHC//First Edit Time: 2014-01-16 14:05//Last Edit Time: 2014-01-16 14:15//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;int n,a[4000];char ha[4000];int main(){ while(~scanf("%d",&n)){ for(int i=0;i<n;i++)scanf("%d",&a[i]); if(n<=0){ puts("Not jolly"); ...
1.6.8 澳大利亚投票 Australian Voting
思路&题解
PC/UVA 110108/10142
模拟。
//author: CHC//First Edit Time: 2014-01-14 14:37//Last Edit Time: 2014-01-15 22:03//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <vector>#include <algorithm>using namespace std;int n,t,ns;char s[30][100];char ts[1000];vector <int> vote[1010];vector <int> ::iterator it;int ha[30];void getnum(int kn){ int i=0; while(ts[i]) { while(ts[i]== ...
1.6.7 将军 Check the Check
思路&题解
PC/UVA 110107/10196
本题略恶心。模拟
//author: CHC//First Edit Time: 2014-01-13 17:11//Last Edit Time: 2014-01-14 13:57//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;char map[10][10];struct jue{ int x,y; char ch;}white[100],black[100];int wn,bn;int getmap(){ int flag=0; bn=wn=0; memset(map,'0',sizeof(map)); for(int i=1;i<=8;i++) for(in ...
1.6.6 解释器 Interpreter
思路&题解
PC/UVA 110106/10033
本题。。模拟即可。
//author: CHC//First Edit Time: 2014-01-12 22:00//Last Edit Time: 2014-01-13 11:30//Filename:1.cpp#include <iostream>#include <cstdio>#include <string.h>#include <queue>#include <algorithm>using namespace std;int n,ord[2000],sum,re[10];char s[2000];int main(){ scanf("%d",&n); getchar(); getchar(); //fgets(s,sizeof(s),stdin); while(n--) { int ns=0; memset(ord,0,sizeof(or ...