Task: | Criminals |
Sender: | david.meichel |
Submission time: | 2018-10-04 18:07:51 +0300 |
Language: | Java |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.14 s | details |
#2 | ACCEPTED | 0.15 s | details |
#3 | ACCEPTED | 0.14 s | details |
#4 | ACCEPTED | 0.15 s | details |
#5 | ACCEPTED | 0.15 s | details |
#6 | ACCEPTED | 0.15 s | details |
#7 | ACCEPTED | 0.14 s | details |
#8 | ACCEPTED | 0.15 s | details |
#9 | ACCEPTED | 0.22 s | details |
#10 | ACCEPTED | 0.20 s | details |
#11 | ACCEPTED | 0.17 s | details |
#12 | ACCEPTED | 0.14 s | details |
#13 | ACCEPTED | 0.23 s | details |
#14 | ACCEPTED | 0.20 s | details |
#15 | ACCEPTED | 0.14 s | details |
#16 | ACCEPTED | 0.15 s | details |
#17 | ACCEPTED | 0.23 s | details |
#18 | ACCEPTED | 0.17 s | details |
#19 | ACCEPTED | 0.23 s | details |
Code
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.StringTokenizer; public class TaskC { public static void main(String[] args) { FastReader reader = new FastReader(); int n = reader.nextInt(); HashSet<Tripel> gangs = new HashSet<Tripel>(); HashSet<Six> ids = new HashSet<Six>(); String line; for (int j = 0;j < n;j++) { line = reader.nextLine(); int[] x = new int[3]; for (int i = 0;i < 3 ;i++) { x [i] = Character.getNumericValue(line.charAt(i)); } int[] y = new int[3]; for (int i = 4;i < 7 ;i++) { y [i-4] = Character.getNumericValue(line.charAt(i)); } Tripel t = checkLine(line, x.clone() ,y.clone()); if(t == null) { System.out.print("QAQ"); return; } else { if (!gangs.contains(t)) gangs.add(t); } Six s = new Six(x[0], x[1],x[2],y[0],y[1],y[2]); if (ids.contains(s)) { System.out.print("QAQ"); return; } else ids.add(s); } System.out.print(gangs.size()); } public static Tripel checkLine(String line, int[] x, int[] y) { int[] unsorted_x = x.clone(); Arrays.sort(y); Arrays.sort(x); if (Arrays.equals(x,y)) { Tripel t = new Tripel(unsorted_x[0], unsorted_x [1], unsorted_x[2]); return t; } return null; } } class Tripel { public int a; public int b; public int c; public Tripel(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } public boolean equals(Object o) { Tripel t = (Tripel) o; if (this.a == t.a && this.b == t.b && this.c == t.c ) { return true; } // end of if return false; } public int hashCode() { return 1; } } class Six { public int a; public int b; public int c; public int d; public int e; public int f; public Six(int a, int b, int c, int d, int e, int f) { this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; } public boolean equals(Object o) { Six t = (Six) o; if (a == t.a && b == t.b && c == t.c && d == t.d && e == t.e && f == t.f) { return true; } return false; } public int hashCode() { return 1; } } class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5 176-671 176-617 176-716 176-167 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: ACCEPTED
input |
---|
3 123-321 123-312 312-123 |
correct output |
---|
2 |
user output |
---|
2 |
Test 3
Verdict: ACCEPTED
input |
---|
2 123-123 123-123 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 4
Verdict: ACCEPTED
input |
---|
2 123-123 123-456 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 5
Verdict: ACCEPTED
input |
---|
1 514-415 |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Verdict: ACCEPTED
input |
---|
8 384-843 384-348 384-834 895-958 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 7
Verdict: ACCEPTED
input |
---|
9 548-845 556-565 626-266 548-458 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 8
Verdict: ACCEPTED
input |
---|
1 966-696 |
correct output |
---|
1 |
user output |
---|
1 |
Test 9
Verdict: ACCEPTED
input |
---|
860 883-838 589-895 172-712 591-951 ... |
correct output |
---|
254 |
user output |
---|
254 |
Test 10
Verdict: ACCEPTED
input |
---|
766 869-968 486-468 295-925 166-616 ... |
correct output |
---|
265 |
user output |
---|
265 |
Test 11
Verdict: ACCEPTED
input |
---|
128 219-912 444-444 372-327 771-771 ... |
correct output |
---|
82 |
user output |
---|
82 |
Test 12
Verdict: ACCEPTED
input |
---|
392 625-625 129-291 451-451 277-772 ... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 13
Verdict: ACCEPTED
input |
---|
868 689-869 737-773 896-689 522-225 ... |
correct output |
---|
222 |
user output |
---|
222 |
Test 14
Verdict: ACCEPTED
input |
---|
533 548-485 143-143 714-471 299-299 ... |
correct output |
---|
295 |
user output |
---|
295 |
Test 15
Verdict: ACCEPTED
input |
---|
1000 128-182 755-755 196-169 674-476 ... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 16
Verdict: ACCEPTED
input |
---|
1000 365-635 476-746 199-919 648-468 ... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 17
Verdict: ACCEPTED
input |
---|
1000 474-744 428-284 532-235 288-288 ... |
correct output |
---|
425 |
user output |
---|
425 |
Test 18
Verdict: ACCEPTED
input |
---|
1000 346-436 573-735 981-918 582-582 ... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 19
Verdict: ACCEPTED
input |
---|
1000 128-128 585-558 487-874 261-162 ... |
correct output |
---|
208 |
user output |
---|
208 |