72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
/*
|
|
* 在线处理?
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
using Boat = pair<int, vector<int>>;
|
|
|
|
constexpr int MAX_N = 1e5 + 5, DAY_TIME = 86400;
|
|
|
|
vector<Boat> boats;
|
|
unordered_map<int, int> nations_statistics;
|
|
int start_time = -DAY_TIME, current_time = 0, pointer = 0, nations_count;
|
|
|
|
void modify_nations_statistics(vector<int> people, int multiplier = 1) {
|
|
for (int nation : people) {
|
|
if (nations_statistics[nation] == 0) { nations_count++; }
|
|
nations_statistics[nation] += multiplier;
|
|
if (nations_statistics[nation] == 0) { nations_count--; }
|
|
}
|
|
}
|
|
|
|
int count_nations() {
|
|
// int ans = 0;
|
|
// for (auto& [nation, count] : nations_statistics) {
|
|
// if (count > 0) { ans++; }
|
|
// }
|
|
// return ans;
|
|
return nations_count;
|
|
}
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(false);
|
|
cin.tie(nullptr);
|
|
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++) {
|
|
int arrival_time, people_amount;
|
|
cin >> arrival_time >> people_amount;
|
|
boats.emplace_back(arrival_time, vector<int>(people_amount));
|
|
for (int j = 0; j < people_amount; j++) {
|
|
cin >> boats.back().second[j];
|
|
}
|
|
// ONLINE
|
|
modify_nations_statistics(boats.back().second);
|
|
start_time = arrival_time - DAY_TIME;
|
|
while (pointer < boats.size() && boats[pointer].first <= start_time) {
|
|
modify_nations_statistics(boats[pointer].second, -1);
|
|
pointer++;
|
|
}
|
|
cout << count_nations() << endl;
|
|
}
|
|
|
|
// for (int i = 0, j = 0; i < boats.size(); i++) {
|
|
// current_time = boats[i].first + DAY_TIME;
|
|
// // modify_nations_statistics(boats[i].second);
|
|
// while (j < boats.size() && boats[j].first <= current_time) {
|
|
// modify_nations_statistics(boats[j].second);
|
|
// j++;
|
|
// }
|
|
// cout << count_nations() << endl;
|
|
// modify_nations_statistics(boats[i].second, -1);
|
|
// }
|
|
|
|
return 0;
|
|
}
|