特征提取
Solutions
#include <bits/stdc++.h>
using namespace std;
#define node(x, y) ((x) * INT_MAX + (y))
int main() {
int sn; cin >> sn;
unordered_map<long, int> prev, cur;
// for each sample
for (int s = 0; s < sn; s++) {
int rn; cin >> rn;
int maxlen = 0;
// for each frame
for (int r = 0; r < rn; r++) {
int pn; cin >> pn;
cur = prev;
// for each feature
for (int p = 0; p < pn; p++) {
long x, y; cin >> x; cin >> y;
long feature = node(x, y);
// each feature in the same row only count once
if (!prev.count(feature) || prev[feature] == cur[feature])
maxlen = max(maxlen, ++cur[feature]);
}
// remove nonduplicate features in the last row
vector<long> remove;
for (auto it : cur) {
long feature = it.first, cnt = it.second;
if (prev.count(feature) && cnt == prev[feature])
remove.push_back(feature);
}
for (auto rm : remove)
cur.erase(rm);
swap(prev, cur);
}
cout << maxlen << endl;
prev.clear(); cur.clear();
}
}Last updated