QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#74110#4780. 完美的队列Larunatrecy0 328ms13160kbC++142.8kb2023-01-30 19:08:552023-01-30 19:08:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-30 19:08:59]
  • 评测
  • 测评结果:0
  • 用时:328ms
  • 内存:13160kb
  • [2023-01-30 19:08:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int n,a[N];
int B,bel[N],L[N],R[N];
int m,l[N],r[N],ele[N];
inline int read()
{
    int X=0;char ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-'0';ch=getchar();}
    return X;
}
int eff[N];
int b[N];
int tag=0,h=0;
void ins(int o,int i,int opt)
{
    if(l[i]<=L[o]&&R[o]<=r[i])tag+=opt;
    else if(l[i]<=R[o]&&r[i]>=L[o])
    {
        for(int x=max(l[i],L[o]);x<=min(r[i],R[o]);x++)b[x]-=opt;
        h=0;
        for(int x=L[o];x<=R[o];x++)h=max(h,b[x]);
    }
}
int s[N];
int cov[N],tot=0;
int dol[N],cnt=0;
int lef[N];
void solve(int o)
{
    //整块的答案
    for(int i=L[o];i<=R[o];i++)b[i]=a[i];
    tag=0,h=0;
    for(int i=L[o];i<=R[o];i++)h=max(h,b[i]);
    int j=0;
    tot=0;cnt=0;
    for(int i=1;i<=m;i++)
    {
        ins(o,i,-1);
        while(j<=m&&h>tag)
        {
            j++;
            ins(o,j,1);
        }
        s[i]=s[i-1];
        if(L[i]<=L[o]&&R[o]<=R[i])
        {
            eff[i]=max(eff[i],j);
            s[i]++;
            cov[++tot]=i;
        }
        else if(l[i]<=R[o]&&r[i]>=L[o])
        {
            dol[++cnt]=i;
            lef[cnt]=tot;
        }
    }
    for(int p=L[o];p<=R[p];p++)
    {
        h=a[p];
        int j=0;
        for(int i=1;i<=cnt;i++)
        {
            h+=s[dol[i]]-s[dol[i-1]];
            if(L[dol[i]]<=p&&p<=R[dol[i]])
            {
                h++;
                while(j<cnt&&h>0)
                {
                    j++;
                    h-=s[dol[j]]-s[dol[j-1]]+(L[dol[j]]<=p&&p<=R[dol[j]]);
                }
                if(h>0)
                {
                    if(h>s[m]-s[dol[j]])eff[dol[i]]=m+1;
                    else eff[dol[i]]=max(eff[dol[i]],cov[lef[j]+h]);
                    continue;
                }
                if(l[dol[j]]<=p&&r[dol[j]]>=p)eff[dol[i]]=max(eff[dol[i]],h<0?cov[lef[j]+h+1]:dol[j]);
                else eff[dol[i]]=max(eff[dol[i]],cov[lef[j]+h]);
            }
        }
    }
}
struct node
{
    int x,v;
};
vector<node> upd[N];
int t[N];
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=1;i<=m;i++)l[i]=read(),r[i]=read(),ele[i]=read();
    B=sqrt(n);
    for(int i=1;i<=n;i++)
    {
        bel[i]=(i-1)/B+1;
        R[bel[i]]=i;
        if(!L[bel[i]])L[bel[i]]=i;
    }
    for(int o=1;o<=bel[n];o++)solve(o);
    for(int i=1;i<=m;i++)
    {
        upd[i].push_back((node){ele[i],1});
        upd[eff[i]].push_back((node){ele[i],-1});
    }
    int now=0;
    for(int i=1;i<=m;i++)
    {
        for(auto U:upd[i])
        {
            int x=U.x,v=U.v;
            if(t[x]==0||t[x]+v==0)now+=v;
            t[x]+=v;
        }
        printf("%d\n",now);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 10292kb

input:

5000 4999
99 36 47 78 58 58 64 12 42 54 29 56 57 32 99 21 1 6 42 97 82 8 79 92 3 56 19 41 29 59 23 34 76 34 82 20 44 51 60 73 89 65 51 65 15 87 65 70 51 26 40 95 44 62 97 81 43 13 20 81 76 64 47 95 54 56 99 62 91 63 98 58 70 60 47 97 31 74 76 70 10 30 99 33 52 100 14 65 4 6 87 4 8 1 8 87 18 70 76 43...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
10...

result:

wrong answer 339th numbers differ - expected: '329', found: '328'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 74ms
memory: 10668kb

input:

25000 25000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
2
3
4
5
6
7
8
6
7
8
6
7
8
6
7
8
9
6
7
6
7
8
2
2
3
4
2
3
2
2
3
2
3
2
3
2
3
2
3
4
5
2
3
4
5
6
2
3
4
5
2
3
4
5
2
3
4
2
3
4
5
2
2
3
4
2
3
4
5
2
3
4
2
3
4
2
3
4
5
6
7
8
9
2
2
3
2
2
3
4
2
2
3
2
3
2
2
2
3
4
2
3
2
3
4
2
3
2
3
2
2
2
3
4
2
2
2
3
4
5
2
3
4
2
2
3
4
5
6
7
8
2
3
2
3
4
5
4
5
6
7
7
4
2
3
4
5
6
7
...

result:

wrong answer 6th numbers differ - expected: '5', found: '6'

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 133ms
memory: 12108kb

input:

34999 35000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

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

result:

wrong answer 14th numbers differ - expected: '11', found: '14'

Subtask #8:

score: 0
Skipped

Dependency #6:

0%

Subtask #9:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 197ms
memory: 11352kb

input:

45000 45000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
65
66
67
68
69
70
69
65
66
67
68
61
59
60
43
37
37
38
39
39
40
41
42
41
42
42
43
39
39
35
35
36
37
36
35
33
31
32
...

result:

wrong answer 18th numbers differ - expected: '17', found: '18'

Subtask #10:

score: 0
Skipped

Dependency #8:

0%

Subtask #11:

score: 0
Skipped

Dependency #5:

0%

Subtask #12:

score: 0
Skipped

Dependency #11:

0%

Subtask #13:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 328ms
memory: 13160kb

input:

65000 65000
5 7 8 6 3 6 8 7 2 3 5 10 9 9 4 3 9 1 2 9 1 1 6 10 1 10 5 4 7 1 9 6 6 8 10 5 8 3 2 5 2 3 6 8 7 3 2 3 6 5 1 10 6 2 4 7 8 1 3 3 5 4 2 5 2 5 3 3 6 7 6 9 5 3 10 3 6 2 8 10 9 10 2 5 4 10 3 3 6 3 5 7 141 3 6 3 10 2 7 6 3 5 9 4 10 1 3 9 9 8 2 5 10 1 7 1 8 5 3 3 7 7 9 7 4 1 9 2 2 4 8 6 10 5 7 3 3...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
76
77
78
79
80
81
82
83
84
85
86
87
87
88
89
90
91
92
93
94
95
96
97
98
99
100
10...

result:

wrong answer 77th numbers differ - expected: '77', found: '76'

Subtask #14:

score: 0
Skipped

Dependency #12:

0%

Subtask #15:

score: 0
Skipped

Dependency #13:

0%

Subtask #16:

score: 0
Skipped

Dependency #14:

0%

Subtask #17:

score: 0
Skipped

Dependency #16:

0%

Subtask #18:

score: 0
Skipped

Dependency #17:

0%

Subtask #19:

score: 0
Skipped

Dependency #18:

0%

Subtask #20:

score: 0
Skipped

Dependency #19:

0%