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 pathbeadsold.java
More file actions
95 lines (73 loc) · 1.87 KB
/
beadsold.java
File metadata and controls
95 lines (73 loc) · 1.87 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
TASK:beads
ID:johnath6
LANG:JAVA
PROG:beads
*/
import java.io.*;
public class beadsold {
public static void main(String[] args) throws IOException {
BufferedReader f=new BufferedReader(new FileReader("beads.in"));
int N=Integer.parseInt(f.readLine());
String beads=f.readLine();
boolean loopagain=true;
String current="";
String a=Character.toString(beads.charAt(0));
int max=0;
int prev=0;
boolean again=true;
boolean condtion;
int debuglevel=0;
for(int j=0;j<N;j++) {
a="!";
for(int i=j;i<N;i++) {
current=Character.toString(beads.charAt(i));
System.out.print(i);
condtion=true;
if(!(current.equals("w")||max==0)&&a.equals("!")) {
debuglevel=2;
condtion=current.equals(a)||current.equals("w");
if(again==false&&i==0) {
debuglevel=1;
condtion=condtion||Character.toString(beads.charAt(N-1)).equals("w");
}
}else if(i!=0) {
condtion=condtion||a.equals("w");
debuglevel=3;
}else if(a.equals("csdfd")){
condtion=true;
}
System.out.println(" "+condtion+"\t"+debuglevel+"\t"+a);
if(condtion) {
max++;
//System.err.println("found");
//System.out.println(current+" "+max);
}else if(loopagain){
a=current;
loopagain=false;
max++;
}else {
if(max>prev) {
prev=max;
max=0;
}
loopagain=true;
a=current;
System.out.println("NEW");
System.out.println("RESULT: "+max);
max=0;
if(again==false) {
break;
}
}
if(i==(beads.length()-1)&&again) {
i=0;
//System.err.println("Debug: Reloop");
again=false;
}
}
again=true;
debuglevel=0;
}
System.out.println(prev);
f.close(); }}