QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784816#9786. Magical Bagsucup-team2172#WA 1ms3804kbC++232.3kb2024-11-26 16:01:502024-11-26 16:01:50

Judging History

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

  • [2024-11-26 16:01:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-11-26 16:01:50]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;

int n, ans;
int L[maxn], R[maxn], f[maxn];
vector<pair<int, int> > all;
vector<int> vec[maxn];

inline void solve_contain(){
    vector<pair<int, int> > all_new;
    sort(all.begin(), all.end(), [&] (const pair<int, int> &ths, const pair<int, int> &oth) { return ths.second < oth.second; });
    int mxl = 0;
    for (auto p: all) {
        if (mxl > p.first) continue; // this interval contains others, single point never contain others
        mxl = max(mxl, p.first);
        if (p.first != p.second) all_new.push_back(p);
    }
    all = all_new;
    // for (auto p: all) printf("(%d %d) ", p.first, p.second); puts("");
}
set<int> sl, sr;
#define IT set<int>::iterator
int main(){
    scanf("%d", &n);
    int ans = 2 * n;
    for (int i = 0; i < n; ++i) {
        int cnt; scanf("%d", &cnt);
        int mn = (int)(1e9) + 1, mx = 1;
        for (int j = 0; j < cnt; ++j) {
            int x; scanf("%d", &x);
            vec[i].push_back(x);
            mn = min(mn, x);
            mx = max(mx, x);
        }
        all.push_back(make_pair(mn, mx));
        sl.insert(mn);
        sr.insert(mx);
    }
    int i = 0;
    for(auto [x , y] : all){
        auto it = sl.lower_bound(y);
        --it;
        if(*it <= x) L[i] = 0;
        else L[i] = *it;
        it = sr.lower_bound(x);
        if(*it >= y) R[i] = 1e9 + 1;
        else R[i] = * it;
        i += 1;
    }
    // solve_contain();

    vector<pair<int, int> > all_new;
    int res = 0;
    for (int i = 0; i < all.size(); ++i) {
        bool flg = false;
        for (auto x: vec[i]) if (x > L[i] && x < R[i]) flg = true;
        if (flg) all_new.push_back(all[i]);
    }
    all = all_new;
    sort(all.begin(), all.end(), [&] (const pair<int, int> &ths, const pair<int, int> &oth) { return ths.second < oth.second; });
    int cur = 0;
    for (int i = 0; i < all.size(); ++i) {
        if(all[i].first > cur){
            ans--;
            cur = all[i].second;
        }
    }

    printf("%d\n", ans);
    return 0;
}

/*
4
3 4 7 10
2 1 9
4 11 2 8 14
3 6 12 13

4
1 1
1 2
1 3
1 4

9
2 1 10
3 2 5 11
2 3 22
2 21 40
3 32 35 41
2 33 62
2 60 100
3 71 75 101
2 72 102
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
3 4 7 10
2 1 9
4 11 2 8 14
3 6 12 13

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3800kb

input:

4
1 1
1 2
1 3
1 4

output:

5

result:

wrong answer 1st numbers differ - expected: '4', found: '5'