qwerty787788

Untitled

Apr 22nd, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. void solve() throws IOException {
  2.         int n = in.nextInt();
  3.         String s1 = in.next();
  4.         String s2 = in.next();
  5.         int x11 = 0;
  6.         int x10 = 0;
  7.         int x01 = 0;
  8.         int x00 = 0;
  9.         for (int i =0; i < n * 2; i++) {
  10.             char c1 = s1.charAt(i);
  11.             char c2 = s2.charAt(i);
  12.             if (c1 == '1' && c2 == '1')
  13.                 x11++;
  14.             if (c1 == '1' && c2 == '0')
  15.                 x10++;
  16.             if (c1 == '0' && c2 == '1')
  17.                 x01++;
  18.             if (c1 == '0' && c2 == '0')
  19.                 x00++;
  20.         }
  21.         int f = 0;
  22.         int s = 0;
  23.         for (int i = 0; i < n; i++) {
  24.             if (x11 > 0) {
  25.                 x11--;
  26.                 f++;
  27.             } else {
  28.                 if (x10 > 0) {
  29.                     x10--;
  30.                     f++;
  31.                 } else {
  32.                     if (x01 > 0) {
  33.                         x01--;
  34.                     } else {
  35.                         x00--;
  36.                     }
  37.                 }
  38.             }
  39.            
  40.             if (x11 > 0) {
  41.                 x11--;
  42.                 s++;
  43.             } else {
  44.                 if (x01 > 0) {
  45.                     x01--;
  46.                     s++;
  47.                 } else {
  48.                     if (x10 > 0) {
  49.                         x10--;
  50.                     } else {
  51.                         x00--;
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.         if (f > s) {
  57.             out.println("First");
  58.             return;
  59.         }
  60.         if (f < s) {
  61.             out.println("Second");
  62.             return;
  63.         }
  64.         out.println("Draw");
  65.        
  66.        
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment