#include #include #include #include "avaliador.h" int correct = 0; int n, q, contador; int robots[MAXN], found[MAXN]; void end(int type) { if (correct) printf("Correto! Usaste %d testes.\n", contador); else { if (type == 0) printf("Incorreto, usaste testes a mais...\n"); else if (type == 1) printf("Incorreto, input invalido...\n"); else if (type == 2) printf("Incorreto, comparacao fora dos limites...\n"); else printf("Incorreto, devolveste a resposta errada ...\n"); } exit(0); } int testar(int p1, int p2) { if (p1 < 1 || p1 > MAXN || p2 < 1 || p2 > MAXN) end(2); contador++; if (robots[p1 - 1] > robots[p2 - 1]) return 1; return 0; } int main() { scanf("%d %d", &n, &q); if (n < 1 || n > MAXN || n % 2 != 1) end(1); if (q < 1 || q > MAXQ) end(1); int i; for (i = 0; i < n; i++) scanf("%d", &robots[i]); for (i = 0; i < n; i++) if (robots[i] < 1 || robots[i] > n) end(1); memset(found, 0, sizeof found); for (i = 0; i < n; i++) { if (found[robots[i]]) end(1); found[robots[i]] = 1; } int resposta = -1; for (i = 0; i < n; i++) if (robots[i] == (n + 1) / 2) resposta = i + 1; contador = 0; if (escolher(n) != resposta) end(3); correct = (contador <= q); end(0); return 0; }