Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() throws IOException {
- int n = in.nextInt();
- String s1 = in.next();
- String s2 = in.next();
- int x11 = 0;
- int x10 = 0;
- int x01 = 0;
- int x00 = 0;
- for (int i =0; i < n * 2; i++) {
- char c1 = s1.charAt(i);
- char c2 = s2.charAt(i);
- if (c1 == '1' && c2 == '1')
- x11++;
- if (c1 == '1' && c2 == '0')
- x10++;
- if (c1 == '0' && c2 == '1')
- x01++;
- if (c1 == '0' && c2 == '0')
- x00++;
- }
- int f = 0;
- int s = 0;
- for (int i = 0; i < n; i++) {
- if (x11 > 0) {
- x11--;
- f++;
- } else {
- if (x10 > 0) {
- x10--;
- f++;
- } else {
- if (x01 > 0) {
- x01--;
- } else {
- x00--;
- }
- }
- }
- if (x11 > 0) {
- x11--;
- s++;
- } else {
- if (x01 > 0) {
- x01--;
- s++;
- } else {
- if (x10 > 0) {
- x10--;
- } else {
- x00--;
- }
- }
- }
- }
- if (f > s) {
- out.println("First");
- return;
- }
- if (f < s) {
- out.println("Second");
- return;
- }
- out.println("Draw");
- }
Advertisement
Add Comment
Please, Sign In to add comment