/C06037 - Vòng tròn

<Problem>

https://code.ptit.edu.vn/student/question/C06037
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define max(i, j) ((i > j) ? i : j)

int main() {
	char s[200];
	gets(s);

	int res = 0;

	for (int i = 0; i < strlen(s) - 1; i++) {
		int p = 0;
		for (int j = i + 1; j < strlen(s); j++) {
			if (s[i] == s[j]) {
				p = j;
			}
		}

		if (p == 0 || p == i + 1) continue;

		int cnt[200] = { 0 };

		for (int j = i + 1; j < p; j++) {
			cnt[s[j]]++;
		}

		for (int j = 'A'; j <= 'Z'; j++) {
			if (cnt[j] == 1) res++;
		}
	}

	printf("%d", res / 2);

	printf("\n");

	return 0;
}