Skip to content

Instantly share code, notes, and snippets.

@viniciustaveira
Created March 8, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniciustaveira/9434907 to your computer and use it in GitHub Desktop.
Save viniciustaveira/9434907 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int n, m, pares = 0, repeticao[31], i;
char L, combinacoes[31];
for(i = 0; i <= 30; i++) repeticao[i] = 0;
scanf("%i", &n);
do{
scanf("%i %c", &m, &L);
if(repeticao[m-30] > 0){
repeticao[m-30]++;
if(combinacoes[m-30] != L){
pares++;
repeticao[m-30]-=2;
}
}else{
combinacoes[m-30] = L;
repeticao[m-30] = 1;
}
if(n == 1){
n = 0;
scanf("%i", &n);
printf("%i\n", pares);
pares = 0;
for(i = 0; i <= 30; i++) repeticao[i] = 0;
}else n--;
}while(n);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment