Google CodeJam – Problem B. Rank and File

https://code.google.com/codejam/contest/4304486/dashboard#s=p1&a=2

the idea is very simple, every items on the matrix will appear even time, therefore, for the row which is missing, all items should have odd times.

the code is following

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int main(int argc,char **argv) 
{ 
  int N;
  int array[3000];
  scanf("%d\n",&N);
 
  for(int i=0;i<N;i++)
  {
	  int T;
	  scanf("%d\n",&T);
	  memset(array,0,sizeof(int)*3000);
 
	  int temp;
	  for(int m=0;m<2*T-1;m++)
	  {
		  for(int n=0;n<T;n++)
		  {
			scanf("%d",&temp);
			array[temp]++;
		  }
	  }
 
	  printf("Case #%d: ",(i+1));
 
	  for(int m=0;m<3000;m++)
	  {
		  if(array[m]>0 && array[m]%2==1)
		  {
			  printf("%d ",m);
		  }
	  }
	  printf("\n");
  }
 
  return 0; 
}