-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
79 lines (70 loc) · 2.16 KB
/
Main.java
File metadata and controls
79 lines (70 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class Main {
static Slide nextSlide(PictureHolder hodler,Slide current){
Set<Image> tags = new HashSet<>();
for(String tag:current.sumOfTags)
tags.addAll(hodler.get(tag));
Slide s = null;
int c = 0;
for(Image img:tags){
if(!img.isUsed)
{
int t =0;
Image img2 = null;
if(!img.isVertical){
t=TagsComparator.imageCompare(current.sumOfTags,img.tags);
}else{
Set<String> sum_tags=new HashSet<>();
img2=hodler.getRVI();
sum_tags.addAll(img.tags);
sum_tags.addAll(img2.tags);
t=TagsComparator.imageCompare(current.sumOfTags,img.tags);
}
if(c<t)
{
if(img2 ==null){
s = new Slide(img);
}
else{
s = new Slide(img,img2);
}
c=t;
}
}
}
if(s!=null) {
s.setUsed();
return s;
}
else
return null;
}
public static void main(String... args) throws IOException {
PictureHolder h = PictureHolder.make_Holder(args[0]);
Set<Image> max_i= h.getLSet();
Image i = PictureHolder.getMaxTags(max_i);
i.isUsed=true;
Slide start = new Slide(i);
Slideshow show = new Slideshow(new ArrayList());
show.add(start);
do {
Slide next = nextSlide(h,show.lastSlide());
if(next!=null)
show.add(next);
else
break;
}while (true);
do {
Slide next = nextSlide(h,show.firstSlide());
if(next!=null)
show.addFront(next);
else
break;
}while (true);
System.out.println(show.points());
Slideshow.submissionFile(show,"out.txt");
}
}