-
Notifications
You must be signed in to change notification settings - Fork 2
/
EraseSecurely.java
41 lines (30 loc) · 1001 Bytes
/
EraseSecurely.java
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
/*
Problem: https://open.kattis.com/problems/erase
Author: Adrian Reithaug
Submitted: June 15th, 2017
Time: 0.09s / 1.00s
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class EraseSecurely {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int overwrites = Integer.parseInt(reader.readLine());
char[] data = reader.readLine().toCharArray();
String verification = reader.readLine();
boolean success = true;
String out = "";
if (overwrites % 2 != 0) {
for (char c : data) {
out += (c == '0') ? "1" : "0";
}
} else {
out = String.copyValueOf(data);
}
if (!out.equals(verification)) {
success = false;
}
System.out.println(success ? "Deletion succeeded" : "Deletion failed");
}
}