제출 #149311

#제출 시각아이디문제언어결과실행 시간메모리
149311오리버스부릉부릉 (#200)함수컵 박물관 (FXCUP4_museum)C++17
100 / 100
147 ms10948 KiB
#include "museum.h"
using namespace std;
typedef long long ll;
char ch[200000];
char ca[200000];

vector<int> aa[100], bb[100], cc[100];

long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
	int n = a.size();

	for (int i = 0; i < n; i++) {
		aa[--a[i]].push_back(i);
		bb[--b[i]].push_back(i);
		cc[--c[i]].push_back(i);
	}

	ll ans = 0;
	
	for (int i = 0; i < 100; i++) {
		int c1 = 0;
		vector<int> tm[100], tb[100];
		// ��ġ�� �ֵ� �߿�...
		// ���ο� b�迭�� �ٽ� �Ѹ���??

		for (int t : aa[i]) {
			ch[t]++;
			c1++;
			tm[b[t]].push_back(t);
			tb[c[t]].push_back(t);
		}

		ans += (c1) * (c1 - 1LL) / 2;
		for (int j = 0; j < 100; j++) {
			vector<int> ttm[100];
			int c2 = 0;
			for (int t : tm[j]) {
				if (ch[t]) {
					ca[t]++;
					c2++;
					ttm[c[t]].push_back(t);
				}
			}
			ans -= (c2) * (c2 - 1LL) / 2;
			
			for (int k = 0; k < 100; k++) {
				int c3 = 0;
				for (int t : ttm[k]) {
					if (ca[t])
						c3++;
				}
				ans += (c3) * (c3 - 1LL) / 2;
				// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
			}

			for (int t : tm[j]) {
				if (ch[t])
					ca[t]--;
			}
		}

		for (int k = 0; k < 100; k++) {
			int c3 = 0;
			for (int t : tb[k]) {
				if (ch[t])
					c3++;
			}
			ans -= (c3) * (c3 - 1LL) / 2;
		}

		for (int t : aa[i])
			ch[t]--;
	}


	// 2��°���� ��ġ�� ��.
	for (int j = 0; j < 100; j++) {
		vector<int> tm[100];

		int c2 = 0;
		for (int t : bb[j]) {
			ca[t]++;
			c2++;
			tm[c[t]].push_back(t);
		}
		ans += (c2) * (c2 - 1LL) / 2;

		for (int k = 0; k < 100; k++) {
			int c3 = 0;
			for (int t : tm[k]) {
				if (ca[t])
					c3++;
			}
			ans -= (c3) * (c3 - 1LL) / 2;
			// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
		}

		for (int t : bb[j]) {
			ca[t]--;
		}
	}



	for (int k = 0; k < 100; k++) {
		int c3 = 0;
		for (int t : cc[k]) {
			c3++;
		}
		ans += (c3) * (c3 - 1LL) / 2;
		// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
	}


	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:107:12: warning: unused variable 't' [-Wunused-variable]
   for (int t : cc[k]) {
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...