This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeads.java
More file actions
81 lines (67 loc) · 1.45 KB
/
beads.java
File metadata and controls
81 lines (67 loc) · 1.45 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
80
81
/*
TASK:beads
ID:johnath6
LANG:JAVA
PROG:beads
*/
import java.io.*;
public class beads {
public static void main(String[] args) throws IOException {
BufferedReader f=new BufferedReader(new FileReader("beads.in"));
PrintWriter pw=new PrintWriter(new FileWriter("beads.debug"));
final int N=Integer.parseInt(f.readLine());
String beads=f.readLine();
String current="USA";
int bit=23;//23 for beta
String a=Character.toString(beads.charAt(0));
int max=0;
int prev=0;
boolean s=true;
boolean second=true;
String thew="";
for(int j=bit;j<N;j++) {
current=Character.toString(beads.charAt(j));
pw.print("DEBUG: ");
pw.println(current.equals("w"));
if((a.equals("w"))) {
if(current.equals(thew)||thew.equals("")) {
a=current;
max++;
}
}
else if(a.equals(current)){
max++;//same
} else if(current.equals("w")) {
thew=a;//assign
a="w";
max++;
}
else {
if(!(second)) {
second=true;
thew="";
System.out.print("|");
if(max>prev) {
prev=max;
max=0;
}
}else {
second=false;
}
if(s&&j==N-1) {
pw.println("DEBUG signal 1");
s=!(s);
j=0;
thew="";
}else if(!(s)) {
break;
}
a=current;
}
System.out.print(current);
}
System.out.println(prev);
pw.close();
f.close();
}
}