QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865693#6390. Inspectionsearlyamazon0 147ms20624kbC++141.9kb2025-01-21 21:12:162025-01-21 21:12:20

Judging History

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

  • [2025-01-21 21:12:20]
  • 评测
  • 测评结果:0
  • 用时:147ms
  • 内存:20624kb
  • [2025-01-21 21:12:16]
  • 提交

answer

// pz3
// O(m^2*logm + q*logq)

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

#define int long long
#define st first
#define nd second

const int mn = 2e5+7;
const int oo = 1e18+7;
const int mxm = 4e6+7;
int n,m,q;
int l[mn], r[mn], s[mn], poms[mn];
set<pair<pair<int,int>, int>> niezal;
map<int,int> odp;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m>>q;
    niezal.insert({{n, 1}, oo});
    vector<pair<int,int>> wyn;
    int czas = 0;
    for (int i = 0; i < m; i++){
        cin>>l[i]>>r[i];
        auto odc = *niezal.lower_bound({{r[i], -1}, -1});
        // cout<<"odc: "<<odc.st.st<<" "<<odc.st.nd<<" "<<odc.nd<<"\n";
        int stczas = czas;
        int ile = 0;
        vector<pair<pair<int,int>, int>> czysc;
        for (auto j : niezal){
            if (j == odc) break;
            wyn.push_back({czas-j.nd, j.st.st-j.st.nd+1});
            czas += j.st.st-j.st.nd+1;
            czysc.push_back(j);
            // ile += 
        }
        wyn.push_back({czas-odc.nd, r[i]-odc.st.nd+1});
        czas += r[i]-odc.st.nd+1;
        niezal.insert({{r[i], 1}, stczas});
        if (r[i] != odc.st.st){
            niezal.insert({{odc.st.st, r[i]+1}, odc.nd});
        }
        niezal.erase(odc);
        for (auto j : czysc) niezal.erase(j);
        // for (auto j : niezal){
        //     cout<<j.st.st<<" "<<j.st.nd<<" "<<j.nd<<"\n";
        // }
        // cout<<"\n";
    }
    for (int i = 0; i < q; i++){
        cin>>s[i];
        poms[i] = s[i];
    }
    sort(wyn.begin(), wyn.end(), greater<pair<int,int>>());
    sort(poms, poms+q, greater<int>());
    int wsk = 0;
    int ter = 0;
    for (int i = 0; i < q; i++){
        while (wsk < (int)wyn.size() && wyn[wsk].st > poms[i]){
            ter += wyn[wsk++].nd;
        }
        odp[poms[i]] = ter;
    }
    for (int i = 0; i < q; i++){
        cout<<odp[s[i]]<<" ";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7680kb

input:

20 20 10
3 16
8 17
17 18
6 16
7 7
3 19
8 13
4 15
5 7
1 18
17 18
3 13
1 10
6 10
2 8
11 18
1 14
9 18
3 16
4 15
8 2 17 19 12 15 7 17 4 3

output:

245 267 128 38 227 183 253 128 267 267 

result:

wrong answer 1st lines differ - expected: '150 165 64 40 122 79 150 64 165 165', found: '245 267 128 38 227 183 253 128 267 267 '

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #18:

score: 0
Wrong Answer
time: 147ms
memory: 20624kb

input:

200000 2000 200000
1 120424
1 117468
1 120525
1 165913
1 120671
1 173649
1 177086
1 160439
1 113657
1 1024
1 172987
1 46445
1 141508
1 72552
1 166171
1 71764
1 129090
1 59615
1 157163
1 44185
1 24107
1 127434
1 157165
1 64831
1 2536
1 138854
1 96084
1 11803
1 162841
1 171842
1 116681
1 47063
1 65296...

output:

319 19342 0 319 185 185 0 4039 0 0 185 319 0 0 0 4039 8795 67453 0 1512 96661 0 0 0 4039 319 185 4039 319 0 0 185 7942 0 185 4039 0 9712 110235481 0 319 9001935 0 185 185 0 0 319 0 1448 1512 185 319 185 0 185 0 185 7169 0 319 0 185 1403656 43055 0 5258 185 0 0 1448 185 185 4039 0 0 0 0 0 0 0 185 0 0...

result:

wrong answer 1st lines differ - expected: '319 15786 0 319 185 185 0 4039...2 0 185 0 319 140410 0 185 4039', found: '319 19342 0 319 185 185 0 4039... 0 185 0 319 157976 0 185 4039 '

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%