QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774374#9557. Temperancefosov#RE 1ms3760kbC++141.3kb2024-11-23 13:09:432024-11-23 13:09:50

Judging History

This is the latest submission verdict.

  • [2024-11-23 13:09:50]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 3760kb
  • [2024-11-23 13:09:43]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;

#define ll long long 
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>

#define N 10010

int cx[N], cy[N], cz[N];

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t; cin >> t;
    while (t --) {
        int n; cin >> n;
        vector<tuple<int, int, int>> arr(n);
        for (int i = 0; i < n; ++ i) {
            int x, y, z; cin >> x >> y >> z;
            arr[i] = make_tuple(x, y, z);
            cx[x] = cy[y] = cz[z] = 0;
        }
        for (auto [x, y, z] : arr) {
            cx[x] ++;
            cy[y] ++;
            cz[z] ++;
        }

        auto f = [&](tuple<int, int, int> a) {
            auto& [x, y, z] = a;
            return max(0, max(cx[x], max(cy[y], cz[z])) - 1);
        };

        sort(arr.begin(), arr.end(), [&](auto& a, auto& b) {
            return f(a) < f(b);
        });

        for (int k = 0, i = 0; k < n; ++ k) {
            while (i < n && f(arr[i]) < k) {
                auto& [x, y, z] = arr[i];
                cx[x] --, cy[y] -- , cz[z] --;
                ++ i;
            }
            cout << i << ' ';
        }
        cout << '\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3760kb

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
Runtime Error

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:


result: