题目链接: 2014-12-1 门禁系统.
code
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int* record = new int[n];
int* count = new int[n] {0, 0};
for (int i = 0; i < n; i++) {
cin >> record[i];
}
for (int i = 0; i < n; i++) {
count[record[i] - 1]++;
cout << count[record[i] - 1] << " ";
}
delete[] record;
return 0;
}