Created
September 16, 2016 17:55
-
-
Save chermehdi/845268e54d6e2c110a194e6e360a7b65 to your computer and use it in GitHub Desktop.
Scorify Quick challenge Before Mcpc
This file contains 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
package com.algorithms; | |
/** | |
* @Author Mehdi Maick | |
* Created on 16/09/2016. | |
*/ | |
import java.util.*; | |
import java.io.*; | |
public class scorifymcpc { | |
static final String sep1 = "---"; | |
static final String sep2 = "----"; | |
public static void solve(FastReader fs, PrintWriter pw) { | |
ArrayList<String> j = new ArrayList<>(); | |
ArrayList<String> c = new ArrayList<>(); | |
boolean ok = true; | |
boolean cont = false; | |
String s; | |
while ((s = fs.nextLine()) != null) { | |
if (s.equals(sep1)) { | |
cont = true; | |
} else if (s.equals(sep2)) { | |
if (j.size() != c.size()) { | |
ok = false; | |
} else { | |
for (int i = 0; i < j.size(); i++) { | |
if (!j.get(i).equals(c.get(i))) { | |
ok = false; | |
break; | |
} | |
} | |
} | |
cont = false; | |
j.clear(); | |
c.clear(); | |
if (ok) { | |
pw.println("Yes"); | |
} else { | |
pw.println("No,WRONG ANSWER"); | |
} | |
ok = true; | |
} else if (cont) { | |
c.add(s); | |
} else { | |
j.add(s); | |
} | |
} | |
} | |
public static void main(String[] args) throws Exception { | |
FastReader fs = new FastReader(System.in); | |
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); | |
solve(fs, pw); | |
fs.close(); | |
pw.close(); | |
} | |
static class FastReader { | |
BufferedReader reader; | |
StringTokenizer st; | |
FastReader(InputStream stream) { | |
reader = new BufferedReader(new InputStreamReader(stream)); | |
st = null; | |
} | |
String next() { | |
while (st == null || !st.hasMoreTokens()) { | |
try { | |
String line = reader.readLine(); | |
if (line == null) { | |
return null; | |
} | |
st = new StringTokenizer(line); | |
} catch (Exception e) { | |
throw new RuntimeException(); | |
} | |
} | |
return st.nextToken(); | |
} | |
String nextLine() { | |
String s = null; | |
try { | |
s = reader.readLine(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return s; | |
} | |
int nextInt() { | |
return Integer.parseInt(next()); | |
} | |
long nextLong() { | |
return Long.parseLong(next()); | |
} | |
double nextDouble() { | |
return Double.parseDouble(next()); | |
} | |
char nextChar() { | |
return next().charAt(0); | |
} | |
int[] nextIntArray(int n) { | |
int[] arr = new int[n]; | |
int i = 0; | |
while (i < n) { | |
arr[i++] = nextInt(); | |
} | |
return arr; | |
} | |
long[] nextLongArray(int n) { | |
long[] arr = new long[n]; | |
int i = 0; | |
while (i < n) { | |
arr[i++] = nextLong(); | |
} | |
return arr; | |
} | |
int[] nextIntArrayOneBased(int n) { | |
int[] arr = new int[n + 1]; | |
int i = 1; | |
while (i <= n) { | |
arr[i++] = nextInt(); | |
} | |
return arr; | |
} | |
long[] nextLongArrayOneBased(int n) { | |
long[] arr = new long[n + 1]; | |
int i = 1; | |
while (i <= n) { | |
arr[i++] = nextLong(); | |
} | |
return arr; | |
} | |
void close() { | |
try { | |
reader.close(); | |
} catch (IOException e) { | |
System.err.println("There's been an error trying closing the reader "); | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment