QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#778269#9557. TemperanceaYi_7#TL 3ms6432kbC++171.2kb2024-11-24 13:44:152024-11-24 13:44:19

Judging History

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

  • [2024-11-24 13:44:19]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:6432kb
  • [2024-11-24 13:44:15]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long

void solve() {
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> cnt(3, std::vector<int>(100007, 0));
    std::vector<std::vector<int>> a(n, std::vector<int>(3));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> a[i][j];
            cnt[j][a[i][j]]++;
        }
    }

    // std::map<int, int> cnt_p;
    std::vector<int> cnt_p(n + 7);
    std::vector<int> p(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            p[i] = std::max(p[i], cnt[j][a[i][j]] - 1);
        }
        cnt_p[p[i]]++;
    }

    int ans = 0;
    auto it = cnt_p.begin();
    for (int i = 0; i < n; i++) {
        // while(it != cnt_p.end() && it->first < i) {
        //     ans += it->second;
        //     it = std::next(it);
        // }
        std::cout << ans << ' ';
        ans += cnt_p[i];
    }
    std::cout << '\n';
}

/*
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
*/

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 6356kb

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: 0ms
memory: 6432kb

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 3...

result: