ACM: 有向欧拉图 图论题 poj 1386 …
来源:互联网 发布:网络安全工程师年薪 编辑:程序博客网 时间:2024/05/21 22:34
There is a large number of magnetic plates on every door. Everyplate has one word written on it. The plates must be arranged intoa sequence in such a way that every word begins with the sameletter as the previous word ends. For example, the word ``acm'' canbe followed by the word ``motorola''. Your task is to write acomputer program that will read the list of words and determinewhether it is possible to arrange all of the plates in a sequence(according to the given rule) and consequently to open thedoor.
Input
Output
If there exists such an ordering of plates, your program shouldprint the sentence "Ordering is possible.". Otherwise, output thesentence "The door cannot be opened.".
Sample Input
3
2
acm
ibm
3
acm
malform
mouse
2
ok
ok
Sample Output
The door cannot be opened.
Ordering is possible.
The door cannot be opened.
题意: 单词连接, 每个单词的最后一个字母是下一个单词的开头, 表示这两个单词连通, 现在要你判断全部
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAXN 100005
#define MAX 30
int n;
char str[MAXN];
int indu[MAX], outdu[MAX];
int p[MAX*MAX], leg[MAX];
bool vis[MAX];
inline int getIndex(char ch)
{
}
void init()
{
}
int find(int x)
{
}
int union_set(int x,int y)
{
}
int main()
{
//
}
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: polay定理 数论题 poj 1286 …
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: 图论题 poj 1135
- ACM: 图论题 BFS + STL + priority…
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1161 (把图重建成…
- ACM: 图论题 poj 1789 (一次AC的水…
- ACM: 图论题 poj 1125 (题意读好久…
- ACM: 图论题 poj 1062 (邻接矩阵+d…
- ACM: 最小费用最大流 图论题 poj 2…
- ACM: 动态规划 华东师范OJ 1244 …
- ACM: 动态规划 黑书上的题目
- ACM: 搜索题 poj 1691 一觉醒来居…
- ACM: 动态规划 poj 1014
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 二分图最大匹配 图论题 poj 2…
- Largest prime 尤拉托斯展那筛选法
- ACM: 图论题+记忆DP poj 2662 (边…
- 进程与线程区别
- ACM: 最大流问题 图论题 poj 2263
- ACM: 简单动态规划题 poj 2955
- 第一章 答疑摘选
- ACM: 树状DP 动态规划题 poj 1463 …