1
In the question asks to form a pair of shoes Right and Left so I used strcmp to compare,I used 1 because the strings have to be different,but I did not have the result that the question asked.
Link to the question https://www.urionlinejudge.com.br/judge/pt/problems/view/1245
Here is my code
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main(void)
{
int i, teste, j, c = 0;
while(scanf("%d", &teste) != EOF)
{
c = 0;
int vet[teste];
char nome[teste][100];
for(i = 0; i < teste; i++)
{
scanf("%d %s", &vet[i], nome[i]);
}
for(i = 0; i < teste; i++)
{
for(j = 0; j < teste; j++)
{
if(vet[i] == vet[j])
{
if(strcmp(nome[i], nome[j]) == 1)
{
c++;
}
}
}
}
printf("%d\n", c);
}
}
The complexity of the code is in order of O(n²), but there is how to do in O(n).
– Vinicius Morais