QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775403#9786. Magical Bagsucup-team3584#WA 0ms3836kbC++231.9kb2024-11-23 15:45:362024-11-23 15:45:38

Judging History

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

  • [2024-11-23 15:45:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-11-23 15:45:36]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> v(n);
    vector<pair<int, int>> in(n), out(n);
    for (int i = 0; i < n; ++i) {
        int m;
        cin >> m;
        v[i].resize(m);
        for (int j = 0; j < m; ++j) {
            cin >> v[i][j];
        }
        sort(v[i].begin(), v[i].end());
        in[i] = {v[i][0], i};
        out[i] = {v[i].back(), i};
    }
    sort(in.begin(), in.end());
    sort(out.begin(), out.end());
    in.emplace_back(2e9, -1);
    out.emplace_back(2e9, -1);

    vector<pair<int, int>> pos(n);
    for (int i = 0; i < n; ++i) {
        pos[in[i].second].first = i;
        pos[out[i].second].second = i;
    }

    int res = 0;
    set<int> st;
    for (int i = 0, j = 0; i < n or j < n;) {
        if (in[i].first <= out[j].first) {
            int idx = in[i].second;
            st.insert(idx);
            i += 1;
        } else {
            int idx = out[j].second;
            if (in[pos[idx].first].first == out[j].first) {
                // 元々1個しか入ってない
                res += 1;
                st.clear();
            } else {
                // 2個以上入ってる
                if (st.find(idx) == st.end()) {
                    res += 2;
                } else {
                    res += 1;
                    st.clear();
                }
            }
            j += 1;
        }
    }
    cout << res << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3836kb

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

input:

4
1 1
1 2
1 3
1 4

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3616kb

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 #4:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

4
1 1
1 2
1 3
1 4

output:

4

result:

ok 1 number(s): "4"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

100
4 372861091 407948190 424244630 359746969
6 568180757 527358812 494745349 665803213 674832670 586694351
4 696340797 775899164 919971335 716827187
4 123145962 344250363 122030550 251739234
4 342654413 368648894 150539766 255189030
1 194505887
3 755984448 736803561 745474041
4 709314938 498953418 ...

output:

175

result:

wrong answer 1st numbers differ - expected: '177', found: '175'