complete 7785.c and 7785.py
This commit is contained in:
40
zeta_C/completed/7785.c
Normal file
40
zeta_C/completed/7785.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct _Item {
|
||||||
|
char name[6];
|
||||||
|
char isin;
|
||||||
|
} Item;
|
||||||
|
|
||||||
|
int comp(const void *a, const void *b) {
|
||||||
|
int cmp = strcmp((*(Item *) a).name, (*(Item *) b).name);
|
||||||
|
|
||||||
|
return -cmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int N;
|
||||||
|
|
||||||
|
scanf("%d", &N);
|
||||||
|
Item res[N + 1];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
char temp[6];
|
||||||
|
scanf("%s %s", res[i].name, temp);
|
||||||
|
if (temp[0] == 'e') {
|
||||||
|
res[i].isin = 1;
|
||||||
|
} else {
|
||||||
|
res[i].isin = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort(res, N, sizeof(Item), comp);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
if (comp(&res[i], &res[i + 1]) == 0) {
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
printf("%s\n", res[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
17
zeta_python/completed/7785.py
Normal file
17
zeta_python/completed/7785.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
print = sys.stdout.write
|
||||||
|
|
||||||
|
N = int(input())
|
||||||
|
d = dict()
|
||||||
|
for _ in range(N):
|
||||||
|
n, t = input().rstrip().split()
|
||||||
|
if t.startswith("e"):
|
||||||
|
d[n] = 1
|
||||||
|
else:
|
||||||
|
d[n] = 0
|
||||||
|
x = sorted([k for k, v in d.items() if v == 1])[::-1]
|
||||||
|
for i in x:
|
||||||
|
print(i)
|
||||||
|
print('\n')
|
||||||
Reference in New Issue
Block a user