QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769505 | #9557. Temperance | YipChip# | WA | 1ms | 3620kb | C++23 | 2.0kb | 2024-11-21 17:57:22 | 2024-11-21 17:57:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef pair<ll, PII> PPI;
const int N = 1e5 + 10;
int n;
int used[3][N];
vector<int> thing[3][N];
struct Node
{
int x, y, z;
}p[N];
bool cmp(PPI x, PPI y)
{
return x > y;
}
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; i ++ )
{
int x, y, z;
cin >> x >> y >> z;
p[i] = {x, y, z};
thing[0][x].push_back(i);
thing[1][y].push_back(i);
thing[2][z].push_back(i);
}
vector<PPI> heap;
for (int i = 1; i <= n; i ++ )
{
if (!used[0][p[i].x]) used[0][p[i].x] = 1, heap.push_back({thing[0][p[i].x].size() - 1, {0, p[i].x}});
if (!used[1][p[i].y]) used[1][p[i].y] = 1, heap.push_back({thing[1][p[i].y].size() - 1, {1, p[i].y}});
if (!used[2][p[i].z]) used[2][p[i].z] = 1, heap.push_back({thing[2][p[i].z].size() - 1, {2, p[i].z}});
}
sort(heap.begin(), heap.end(), cmp);
vector<int> ans(n), st(n + 1);
int now = 0, res = 0, len = heap.size();
for (int i = n - 1; i >= 0; i -- )
{
while (now < len && heap[now].first >= i)
{
int fir = heap[now].second.first, sec = heap[now].second.second;
for (auto t : thing[fir][sec])
{
if (st[t]) continue;
st[t] = 1, res ++ ;
}
now ++ ;
}
if (res == n) break;
ans[i] = n - res;
}
for (int i = 0; i < n; i ++ ) cout << ans[i] << " \n"[i == n - 1];
for (int i = 1; i < n; i ++ )
{
used[0][p[i].x] = used[1][p[i].y] = used[2][p[i].z] = 0;
vector<int> tmp1, tmp2, tmp3;
swap(tmp1, thing[0][p[i].x]);
swap(tmp2, thing[1][p[i].y]);
swap(tmp3, thing[2][p[i].z]);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while (T -- ) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
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: 1ms
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 1 2 0 0 0 0 0 0 0 0 0 0 1 5 0 0 0 0 6 6 0 0 0 0 7 7 7 0 0 0 0 8 8 8 8 0 1 2 0 0 0 0 0 0 0 0 0 0 1 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 2nd numbers differ - expected: '0', found: '1'