QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769465#9557. TemperanceYipChip#TL 23ms12948kbC++231.8kb2024-11-21 17:46:442024-11-21 17:46:46

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 17:46:46]
  • 评测
  • 测评结果:TL
  • 用时:23ms
  • 内存:12948kb
  • [2024-11-21 17:46:44]
  • 提交

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;
struct Node
{
    int x, y, z;
}p[N];

bool cmp(PPI x, PPI y)
{
    return x > y;
}

void solve()
{
    int n;
    cin >> n;
    int maxn = 1e5 + 10;
    vector<vector<vector<int>>> thing(3, vector<vector<int>>(maxn));
    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;
    vector<vector<int>> used(3, vector<int>(maxn));
    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;
    for (int i = n - 1; i >= 0; i -- )
    {
        while (now < heap.size() && 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];
}

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: 8ms
memory: 12932kb

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: 0
Accepted
time: 23ms
memory: 12948kb

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 1 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 1 5
0 0 0 0 6 6
0 0 0 0 7 7 7
0 0 0 0 8 8 8 8

result:

ok 72 numbers

Test #3:

score: -100
Time Limit Exceeded

input:

10000
22
1 4 4
7 2 6
6 5 4
4 4 1
1 7 1
7 6 6
5 8 6
4 4 8
6 7 6
1 7 3
5 7 8
5 1 3
2 1 7
1 2 5
6 1 2
3 1 1
7 3 8
1 4 6
6 5 7
4 4 7
7 7 5
3 4 6
13
2 7 3
2 7 5
5 1 5
8 7 1
6 6 7
3 5 8
8 1 6
4 8 4
1 4 3
6 2 5
6 8 4
1 5 5
5 3 4
28
4 7 2
3 8 5
1 1 6
1 7 4
5 5 6
6 1 5
4 5 2
1 1 5
2 6 3
4 3 6
4 5 7
3 3 6
6 8...

output:

0 0 0 0 7 12 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
0 0 3 9 13 13 13 13 13 13 13 13 13
0 0 0 0 8 21 21 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28
0 0 1 9 9 14 14 14 14 14 14 14 14 14
0 0 0 6 9 12 12 19 19 19 19 19 19 19 19 19 19 19 19
0 0 0 0 3 8 10 22 36 36 36 36 36 36 ...

result: