QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790642 | #9557. Temperance | ucup-team5217# | WA | 0ms | 3620kb | C++23 | 2.0kb | 2024-11-28 14:22:35 | 2024-11-28 14:22:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve(void) {
int n;
cin >> n;
vector<int> values;
vector<vector<int>> col(n + 1);
for (int i = 1; i <= n; i++)
for (int t = 0, x; t < 3; t++) cin >> x, x += t * 1e5, col[i].push_back(x), values.push_back(x);
sort(values.begin(), values.end());
values.resize(unique(values.begin(), values.end()) - values.begin());
vector<unordered_set<int>> pnts(values.size());
vector<unordered_set<int>> rec(n + 1);
for (int i = 1; i <= n; i++)
for (auto &x : col[i]) pnts[x = lower_bound(values.begin(), values.end(), x) - values.begin()].insert(i);
for (int i = 0; i < (int)pnts.size(); i++) rec[pnts[i].size()].insert(i);
vector<int> ans(n), cnt(n + 1);
// for (int i = 1; i <= n; i++) {
// cerr << i << ':';
// for (auto j : col[i]) cerr << j << ' ';
// cerr << endl;
// }
for (int k = 1; k < n; k++) {
queue<int> que;
for (auto v : rec[k])
for (auto p : pnts[v])
if (++cnt[p] == 3) que.push(p);
ans[k] = ans[k - 1];
// cerr << "# " << k << ':';
// for (int i = 1; i <= n; i++) cerr << cnt[i] << ' ';
// cerr << endl;
while (!que.empty()) {
int p = que.front();
que.pop();
ans[k]++;
for (auto i : col[p]) {
if ((int)pnts[i].size() < k) continue;
rec[pnts[i].size()].erase(i);
pnts[i].erase(p);
rec[pnts[i].size()].insert(i);
if ((int)pnts[i].size() < k)
for (auto p : pnts[i])
if (++cnt[p] == 3) que.push(p);
}
}
}
for (auto i : ans) cout << i << ' ';
cout << endl;
return;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int _ = 1;
cin >> _;
while (_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
2 5 1 1 1 1 1 2 1 1 3 2 3 5 2 2 4 3 1 1 1 2 2 2 3 3 3
output:
0 0 2 5 5 0 3 3
result:
ok 8 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3620kb
input:
16 1 1 1 1 2 1 1 1 1 1 100000 3 1 1 1 1 1 100000 1 100000 1 4 1 1 1 1 1 100000 1 100000 1 1 100000 100000 5 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 6 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 100000 1 100000 7 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 100000 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0 0 0 0 6 6 0 0 0 0 7 7 7 0 0 0 0 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0 0 0 0 6 6 0 0 0 0 7 7 7 0 0 0 0 8 8 8 8
result:
wrong answer 14th numbers differ - expected: '1', found: '5'