I am in poor status recently. I always love to make low-level mistakes. I have nothing to talk about. What I want to talk about is that Floyd may judge to close the package.
void Floyd() { for(int k=1; k<=n; k++) for(int i=1; i<=n; i++) if(map[i][k]) for(int j=1; j<=n; j++) if(map[k][j]) map[i][j] = 1; }
I have done a lot of graph theory before, and I feel that graph theory can cope with it in the past.
14059727 |
247 |
Calling circles |
Accepted |
C ++ |
0.058 |
12:21:42 |
# Include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # include <vector> # include <stack> # include <queue> # include <map> # include <set> # include <list> # include <cmath> # include <string> # include <sstream> # include <ctime> using namespace STD; # DEFINE _ pI ACOs (-1.0) # define ESP 1e-9 # define INF 1 <30 typedef long ll; typedef unsigned long ull; typedef pair <int, int> pill; /* ====================================== ====================================== Kinderriven ==== ========================================================== =======================*/# define maxd 25 + 1int N, m; Map <string, int> name; vector <string> name; int G [maxd] [maxd], ID; int vis [maxd]; void Init () {name. clear (); Name. clear (); Id = 0; memset (G, 0, sizeof (g); memset (VIS, 0, sizeof (VIS);} void DFS (int u) {vis [u] = 1; for (INT I = 0; I <n; I ++) if (G [u] [I] = 1 & G [u] [I] = G [I] [U]) {If (! Vis [I]) {cout <"," <name [I]; DFS (I) ;}} int main () {int case = 1; while (CIN> N> m) {Init (); If (! N &&! M) break; For (INT I = 0; I <m; I ++) {string S1, S2; CIN> S1> S2; If (! Name. Count (S1) {name [S1] = ID ++; name. push_back (S1) ;}if (! Name. count (S2) {name [s2] = ID ++; Name. push_back (S2);} int x = Name [S1], y = Name [s2]; /* Find the ID of the two strings */g [x] [Y] = 1;/* connect */} For (int K = 0; k <N; k ++) for (INT I = 0; I <n; I ++) if (G [I] [k]) for (Int J = 0; j <N; j ++) if (G [k] [J]) {G [I] [J] = 1;} If (Case> 1) cout <Endl; cout <"calling circles for Data Set" <Case ++ <":" <Endl; For (INT I = 0; I <n; I ++) {If (! Vis [I]) {cout <name [I]; DFS (I); cout <Endl ;}} return 0 ;} /* 5 5A ba BC de C */