Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit d6f167e

Browse files
authored
Add files via upload
1 parent c188689 commit d6f167e

File tree

6 files changed

+160
-11
lines changed

6 files changed

+160
-11
lines changed
3.72 KB
Binary file not shown.
2.72 KB
Binary file not shown.
-168 Bytes
Binary file not shown.

Code-Forces/src/StoTConverter.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import java.util.*;
2+
import java.util.stream.Collectors;
3+
public class StoTConverter {
4+
public static void main(String[] args) {
5+
Scanner sc = new Scanner(System.in);
6+
int N = sc.nextInt();sc.nextLine();
7+
for(int run = 0; run < N; run++) {
8+
9+
String s = sc.nextLine(),t = sc.nextLine(),p = sc.nextLine();
10+
ArrayList<Character> needed = new ArrayList<Character>();
11+
System.out.println("s:"+s+"\n"+"t:"+t+"\n"+"p:"+p);
12+
try {
13+
int min = Integer.min(s.length(),t.length());
14+
for(int i = 0; i < min; i ++) {
15+
if(!(s.charAt(i) == t.charAt(i))) {
16+
throw new Exception("SOLUTION REQUIRES REORDER");
17+
}
18+
}
19+
for(int i =0 ; i < t.length(); i ++) {
20+
//System.out.println("add "+i);
21+
needed.add(t.charAt(i));
22+
}
23+
System.out.println("End Result: "+needed);
24+
for(int i =0 ; i < s.length(); i ++) {
25+
needed.remove(needed.indexOf(s.charAt(i)));
26+
}
27+
System.out.println("Letters needed: "+needed);
28+
29+
List<Character> chars = p.chars() // IntStream
30+
.mapToObj(e -> (char)e) // Stream<Character>
31+
.collect(Collectors.toList());
32+
//System.out.println("Letters to find: "+needed);
33+
System.out.println("Letters to be used before: "+chars);
34+
for(char c: needed) {
35+
//chars.remove(Character.valueOf(c));
36+
chars.remove(chars.indexOf(c));
37+
}
38+
System.out.println("Letters to be used after: "+chars);
39+
System.out.println("YES");
40+
}catch(Exception e) {
41+
System.out.println("NO "+e.getLocalizedMessage());
42+
}
43+
44+
}
45+
}
46+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction;
5+
public class japanese_majhong {
6+
static List<Integer> m,p,s;
7+
public static int maxConsect;
8+
public static int maxSame;
9+
public static int consect_count;
10+
public static int same_count;
11+
public static void process(List<Integer> l){
12+
maxConsect = 0;
13+
maxSame = 0;
14+
consect_count = 0;
15+
same_count = 0;
16+
boolean isConsecutive = false;
17+
boolean isSame = false;
18+
int prev = -1;
19+
for(int num:l) {
20+
if(isConsecutive == false && isSame == false) {
21+
isConsecutive = true;
22+
isSame = true;
23+
consect_count ++;
24+
same_count ++;
25+
}else {
26+
if(prev == (num - 1)) {
27+
isConsecutive = true;
28+
}else if(prev == num) {
29+
isSame = true;
30+
}
31+
if(isConsecutive) {
32+
if(prev == (num - 1)) {
33+
isConsecutive = true;
34+
consect_count++;
35+
}else {
36+
isConsecutive = false;
37+
}
38+
}
39+
if(isSame) {
40+
if(prev == num) {
41+
isSame = true;
42+
same_count++;
43+
}
44+
}else{
45+
isSame = false;
46+
}
47+
48+
}
49+
if(same_count > maxSame){
50+
maxSame = same_count;
51+
}
52+
if(consect_count > maxConsect) {
53+
maxConsect = consect_count;
54+
}
55+
prev = num; // Keep at end
56+
}
57+
}
58+
public static void main(String[] args) {
59+
Scanner sc = new Scanner(System.in);
60+
m = new ArrayList<Integer>();
61+
p = new ArrayList<Integer>();
62+
s = new ArrayList<Integer>();
63+
//System.out.println(s);
64+
for(int i = 0; i < 3; i ++) {
65+
String str = sc.next();
66+
String suit = str.substring(1);
67+
//System.out.println(suit);
68+
int num = Integer.parseInt(str.substring(0, 1));
69+
if(suit.equals("m")) {
70+
m.add(num);
71+
}else if(suit.equals("p")) {
72+
p.add(num);
73+
}else if(suit.equals("s")) {
74+
s.add(num);
75+
}
76+
}
77+
m.sort(null);
78+
p.sort(null);
79+
s.sort(null);
80+
int ans;
81+
int maxMaxSame = -1;
82+
int maxMaxConsect = -1;
83+
//System.out.println("m");
84+
process(m);
85+
maxMaxSame = maxSame;
86+
maxMaxConsect = maxConsect;
87+
//System.out.println(maxConsect+" "+maxSame);
88+
//System.out.println("p");
89+
process(p);
90+
maxMaxSame = Integer.max(maxSame, maxMaxSame);
91+
maxMaxConsect = Integer.max(maxConsect, maxMaxConsect);
92+
//System.out.println(maxConsect+" "+maxSame);
93+
//System.out.println("s");
94+
process(s);
95+
maxMaxSame = Integer.max(maxSame, maxMaxSame);
96+
maxMaxConsect = Integer.max(maxConsect, maxMaxConsect);
97+
//System.out.println(maxConsect+" "+maxSame);
98+
System.out.println(Integer.min(3 - maxMaxSame, 3 - maxMaxConsect));
99+
}
100+
101+
}

Code-Forces/src/vus_cossack_strings.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public static void main(String[] args) {
1919
sc.close();
2020
int lenA = a.length();
2121
int len = b.length();
22-
List<String> substrings = new ArrayList<String>();
22+
int count = 0;
23+
//List<String> substrings = new ArrayList<String>();
2324
/*
2425
for(int i = 0 ; i < lenA; i ++) {
2526
if(a.charAt(i) == 1) {
@@ -29,19 +30,20 @@ public static void main(String[] args) {
2930
}
3031
}
3132
*/
32-
for(int i = 0; i < lenA; i++) {
33-
if(i + len > lenA) {
34-
break;
35-
}
36-
substrings.add(a.substring(i, i + len));
37-
}
38-
int count = 0;
39-
//System.out.println(substrings);
40-
for(String s:substrings) {
41-
if(diff(s,b) % 2 == 0) {
33+
int N = lenA - len + 1;
34+
for(int i = 0; i < N; i++) {
35+
//if(i + len > lenA) {
36+
// break;
37+
//}
38+
//substrings.add();
39+
System.out.println(i+"\n"+(i+len));
40+
if(diff(a.substring(i, i + len),b) % 2 == 0) {
4241
count++;
4342
}
4443
}
44+
45+
//System.out.println(substrings);
46+
4547
System.out.println(count);
4648
}
4749

0 commit comments

Comments
 (0)