Created
September 6, 2010 14:56
-
-
Save chaoxu/567133 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.math.*; | |
public class MultiWordIntersection{ | |
public static int MultiIntersection(ArrayList<String> a, String sword){ | |
int sum = 0; | |
SurfaceWord sw = new SurfaceWord(sword); | |
for(int i=0;i<a.size();i++){ | |
WordVector p = new WordVector(sw.toNumber(a.get(i))); | |
for(int j=i+1;j<a.size();j++){ | |
WordVector p1 = new WordVector(sw.toNumber(a.get(j))); | |
sum + = p.intersection(p1,sw); | |
} | |
sum-= p.selfIntersection(sw) * (a.size()-2); | |
} | |
return sum; | |
} | |
public static int MaxMultiIntegersection(ArrayList<ArrayList<String>> a, String sword){ | |
int m = 0; | |
for(int i=0;i<a.size();i++){ | |
m = Math.max(MultiIntersection(a.get(i), sword),m); | |
} | |
return m; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment