Cod sursa(job #1212922)

Utilizator MarronMarron Marron Data 26 iulie 2014 15:34:38
Problema Secventa Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.65 kb
#include <iostream>
#include <fstream>
using namespace std;

// <parsing>
FILE* f = fopen("avarcolaci.in", "r");
const int maxb = 8192;
char buf[maxb];
int ptr = maxb;

inline int getInt()
{
    while (buf[ptr] < '0' || buf[ptr] > '9') {
        if (++ptr >= maxb) {
            fread(buf, maxb, 1, f);
            ptr = 0;
        }
    }
    int nr = 0;
    while ('0' <= buf[ptr] && buf[ptr] <= '9') {
        nr = nr * 10 + buf[ptr] - '0';
        if (++ptr >= maxb) {
            fread(buf, maxb, 1, f);
            ptr = 0;
        }
    }
    return nr;
}
void reset()
{
    fclose(f);
    f = fopen("avarcolaci.in", "r");
    ptr = maxb;
}
// </parsing>
FILE* g = fopen("avarcolaci.out", "w");

void read_crap(int id)
{
    int trash, n;
    trash = getInt();
    for (int i = 1; i < id; i++) {
        n = getInt();
        for (int j = 1; j <= n * 2; j++) {
            trash = getInt();
        }
    }
}

void do_test(int id)
{
    int n, el, s = 0;
    n = getInt();
    for (int i = 1, x; i <= n * 2; i++) {
        x = getInt();
        if (s == 0) {
            s = 1;
            el = x;
        } else if (x == el) {
            s++;
        } else {
            s--;
        }
    }

    reset();
    read_crap(id);

    s = 0;
    n = getInt();
    for (int i = 1, x; i <= n * 2; i++) {
        x = getInt();
        if (x == el) {
            s++;
        }
    }

    if (s <= n) {
        fprintf(g, "Mozart\n");
    } else {
        fprintf(g, "%d\n", el);
    }
}

int main()
{
    int t;
    t = getInt();
    for (int i = 1; i <= t; i++) {
        do_test(i);
    }
}