#P2970. USACO(24)排序7:奶牛集体照P3034 [USACO11DEC] Cow Photography G/S

USACO(24)排序7:奶牛集体照P3034 [USACO11DEC] Cow Photography G/S

Description

5 
20 30 40 50 10 
20 10 30 40 50 
30 10 20 40 50 
40 10 20 30 50 
50 10 20 30 40
10 
20 
30 
40 
50

Hint

by hansang:
#include<bits/stdc++.h>
using namespace std;
const int N=2e4+10;
int a[N]; map<int, int> mp[7];
bool cmp(int x, int y){
	int res=0;
	for(int i=1; i<=5; i++){
		if(mp[i][x]<mp[i][y]) res++;
	}
	return (res>=3);
}
int main(){
	int n; scanf("%d", &n);
	for(int i=1; i<=5; i++) 
		for(int j=1; j<=n; j++){
			scanf("%d", &a[j]);
			mp[i][a[j]]=j;
		}
	sort(a+1, a+n+1, cmp);
	for(int i=1; i<=n; i++) printf("%d\n", a[i]);
	printf("\n");
	return 0;
}