-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSER14.c
112 lines (108 loc) · 2.38 KB
/
SER14.c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <stdio.h>
void swap(int *a, int *b)
{
int t;
t = *a;
*a = *b;
*b = t;
}
void qsort(int items[][4], int left, int right)
{
register int i, j, k;
int x, y;
i = left;
j = right;
x = items[(left + right) / 2][3];
do
{
while ((items[i][3] < x) && (i < right))
i++;
while ((x < items[j][3]) && (j > left))
j--;
if (i <= j)
{
y = items[i][0];
items[i][0] = items[j][0];
items[j][0] = y;
y = items[i][1];
items[i][1] = items[j][1];
items[j][1] = y;
y = items[i][2];
items[i][2] = items[j][2];
items[j][2] = y;
y = items[i][3];
items[i][3] = items[j][3];
items[j][3] = y;
i++;
j--;
}
} while (i <= j);
if (left < j)
qsort(items, left, j);
if (i < right)
qsort(items, i, right);
}
int main()
{
int i, k, j, n, z, g, count = 0;
int p, q, r;
int arr[100000][4] = {0};
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d %d %d", &arr[i][0], &arr[i][1], &arr[i][2]);
arr[i][3] = arr[i][0] + arr[i][1] + arr[i][2];
if (arr[i][0] > arr[i][1])
swap(&arr[i][0], &arr[i][1]);
if (arr[i][1] > arr[i][2])
swap(&arr[i][1], &arr[i][2]);
if (arr[i][0] > arr[i][1])
swap(&arr[i][0], &arr[i][1]);
}
qsort(arr, 0, n - 1);
i = 0;
while (1)
{
p = arr[i][0];
q = arr[i][1];
r = arr[i][2];
k = arr[i][3];
j = i;
z = 0;
if (p == 0)
{
++i;
if (i == n)
break;
else
continue;
}
//author Anas Khan
while (arr[++i][3] == k && i < n)
{
if (arr[i][0] != 0 && arr[i][0] == p && arr[i][1] == q && arr[i][2] == r)
{
arr[i][0] = 0;
z++;
}
}
if (z != i - 1 - j && z >= 1)
{
i = j + 1;
continue;
}
else if (z == 0)
{
count++;
if (i != j + 1)
{
i = j + 1;
continue;
}
}
if (i == n)
break;
}
printf("%d", count);
return 0;
}