QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#755490 | #9557. Temperance | ucup-team3670# | WA | 0ms | 3672kb | C++20 | 2.0kb | 2024-11-16 17:29:18 | 2024-11-16 17:29:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sz(a) ((int)((a).size()))
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> ptt;
typedef long long li;
typedef long double ld;
const li INF64 = (li)(1e18);
const int INF = (int)(1e9);
int n;
vector<vector<int>> a;
bool read()
{
if(!(cin >> n))
{
return false;
}
a.resize(n);
forn(i, n){
a[i].resize(3);
forn(j, 3) cin >> a[i][j];
}
return true;
}
void solve()
{
forn(j, 3){
vector<int> xs;
forn(i, n) xs.push_back(a[i][j]);
sort(xs.begin(), xs.end());
forn(i, n) a[i][j] = lower_bound(xs.begin(), xs.end(), a[i][j]) - xs.begin();
}
vector<set<int>> cur(3 * n + 1);
vector<int> cnt(3 * n);
vector<vector<int>> who(3 * n);
vector<int> rank(n, 3);
forn(i, n) forn(j, 3) ++cnt[j * n + a[i][j]];
forn(i, n) forn(j, 3) cur[cnt[j * n + i]].insert(j * n + i);
forn(i, n) forn(j, 3) who[j * n + a[i][j]].push_back(i);
vector<int> ans(n);
int rem = 0;
queue<int> q;
int k = 1;
auto upd = [&](int x){
assert(cur[cnt[x]].count(x));
cur[cnt[x]].erase(x);
for (int i : who[x]){
--rank[i];
if (rank[i] == 0){
q.push(i);
++rem;
}
}
};
for (; k < n; ++k){
vector<int> nw(cur[k].begin(), cur[k].end());
for (int x : nw) upd(x);
while (!q.empty()){
int i = q.front();
q.pop();
forn(j, 3){
int val = j * n + a[i][j];
if (cnt[val] < k) continue;
cur[cnt[val]].erase(val);
--cnt[val];
cur[cnt[val]].insert(val);
if (cnt[val] < k) upd(val);
}
}
ans[k] = rem;
}
forn(i, n) cout << ans[i] << ' ';
cout << '\n';
}
int main(){
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
#endif
cin.tie(0);
ios::sync_with_stdio(false);
int tc = 1;
cin >> tc;
while(tc > 0)
{
--tc;
read();
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3672kb
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'