QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#557719#8672. 排队zhulexuan0 165ms71184kbC++142.5kb2024-09-11 11:07:592024-09-11 11:08:00

Judging History

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

  • [2024-09-11 11:08:00]
  • 评测
  • 测评结果:0
  • 用时:165ms
  • 内存:71184kb
  • [2024-09-11 11:07:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
    T w=1; n=0; char ch=getchar();
    while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
    while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
    n*=w;
}
template<typename T>inline void write(T x){
    if (x==0){ putchar('0'); return ; }
    T tmp;
    if (x>0) tmp=x;
    else tmp=-x;
    if (x<0) putchar('-');
    char F[105];
    long long cnt=0;
    while (tmp){
        F[++cnt]=tmp%10+48;
        tmp/=10;
    }
    while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
const ll N = 1000005;
ll n,q;
ll a[N],b[N];
ll ql[N],qr[N];
ll af[N];
vector<ll> c[N];
struct Tree{
    struct node{
        ll l,r;
        ll mn,mx,tag;
    }t[4*N];
    void build(ll s,ll l,ll r){
        t[s].l = l; t[s].r = r;
        t[s].mn = t[s].mx = t[s].tag = 0;
        if (l==r) return ;
        ll mid = (l+r)>>1;
        build(s*2,l,mid);
        build(s*2+1,mid+1,r);
    }
    void chg(ll s,ll v){
        t[s].mn += v;
        t[s].mx += v;
        t[s].tag += v;
    }
    void down(ll s){
        chg(s*2,t[s].tag);
        chg(s*2+1,t[s].tag);
        t[s].tag = 0;
    }
    void add(ll s,ll lim,ll l,ll r){
        if (t[s].mn>l || t[s].mx<l || t[s].l>lim) return ;
        if (l<=t[s].mn && r>=t[s].mx && t[s].r<=lim){ chg(s,1); return ; }
        down(s);
        add(s*2,lim,l,r);
        add(s*2+1,lim,l,r);
        t[s].mx = max( t[s*2].mx , t[s*2+1].mx );
        t[s].mn = min( t[s*2].mn , t[s*2+1].mn );
    }
    ll qry(ll s,ll x){
        if (t[s].l==t[s].r) return t[s].mn;
        down(s);
        if (t[s*2].r>=x) return qry(s*2,x);
        else return qry(s*2+1,x);
    }
}tr;
int main(){
	// freopen("a.in","r",stdin);
//	freopen(".out","w",stdout);
    ll i,j;
    read(n); read(q);
    fr(i,1,n) read(a[i]), read(b[i]);
    fr(i,1,q) read(ql[i]), read(qr[i]);
    fr(i,1,q) c[qr[i]].push_back(i);
    tr.build(1,1,n);
    fr(i,1,n){
        tr.add(1,i,a[i],b[i]);
        for (j=0; j<c[i].size(); j++){
            ll id = c[i][j];
            af[id] = tr.qry(1,ql[id]);
        }
    }
    fr(i,1,q) printf("%lld\n",af[i]);
    return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000 -std=c++11 -O2

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 36724kb

input:

3 3
0 0
1 2
0 2
1 1
1 3
2 3

output:

1
3
1

result:

ok 3 number(s): "1 3 1"

Test #2:

score: 0
Wrong Answer
time: 4ms
memory: 39292kb

input:

5000 5000
5 10
3 9
3 8
2 7
2 5
3 6
1 5
0 2
7 8
2 10
0 3
3 6
4 6
1 6
4 8
7 8
2 7
3 4
4 9
7 8
2 9
2 5
3 6
0 5
6 7
1 2
2 4
2 10
1 5
7 9
6 9
2 3
9 10
5 5
2 9
3 3
2 7
2 4
0 6
0 3
1 7
7 7
4 8
2 9
4 8
0 10
1 8
1 1
2 7
5 9
1 7
1 7
1 4
2 4
1 4
2 9
1 7
4 7
3 8
1 3
4 6
1 5
1 6
0 0
3 9
4 7
2 8
1 8
1 2
7 8
2 7
2...

output:

11
11
11
10
10
10
11
10
11
8
9
10
11
10
11
10
10
10
10
10
11
11
11
11
10
10
6
9
11
10
10
10
11
11
10
10
10
11
11
10
9
11
10
10
10
11
11
10
10
10
10
10
10
10
10
10
10
9
11
11
11
11
11
11
10
11
10
10
10
10
8
11
11
11
10
11
7
11
11
10
10
7
10
10
10
11
11
11
11
11
10
10
11
11
9
9
10
11
6
10
11
10
11
3
1...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 117ms
memory: 71184kb

input:

200000 200000
3 6
3 3
6 10
1 7
2 7
6 9
4 6
3 4
0 8
0 6
3 5
3 4
1 8
7 8
4 5
0 3
1 5
2 9
1 2
1 2
3 4
5 7
6 10
3 9
4 7
1 6
2 6
1 7
2 5
1 7
6 8
1 1
0 7
7 8
0 9
1 7
3 8
3 7
1 2
4 8
5 6
0 6
5 6
2 7
2 6
0 6
0 6
1 7
2 5
0 3
0 3
7 10
3 8
0 2
3 4
3 7
4 9
0 6
4 7
2 6
8 10
2 10
4 10
3 3
2 6
4 5
3 9
1 8
1 2
2 9
...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 165ms
memory: 67380kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:

7
4
6
3
7
4
5
7
8
13
6
8
4
8
7
9
5
7
7
6
8
6
4
7
7
4
5
7
9
9
7
6
7
2
9
7
5
8
5
6
10
11
7
7
9
6
12
7
9
5
7
6
10
6
7
3
7
6
5
7
7
6
8
5
5
8
9
7
7
7
4
8
8
7
8
7
6
9
3
5
3
7
8
6
3
7
8
6
6
9
2
6
7
7
6
6
5
9
6
6
10
3
4
7
7
4
6
9
6
7
6
9
7
5
4
10
9
6
5
10
7
6
7
3
8
5
8
10
5
9
5
9
12
4
4
5
7
7
7
7
4
7
10
6
5...

result:

wrong answer 1st numbers differ - expected: '19141', found: '7'

Subtask #4:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 158ms
memory: 69932kb

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:

23
34
27
18
29
20
20
28
28
16
27
26
25
15
23
25
23
19
21
25
34
28
13
20
27
29
30
24
8
21
20
25
18
27
29
24
22
31
26
19
22
30
26
29
25
27
26
33
27
20
27
34
37
27
21
24
30
24
23
14
25
22
15
30
19
25
26
22
26
21
25
20
35
31
27
30
18
23
21
35
26
19
26
32
20
16
28
10
22
29
29
30
27
20
25
25
24
30
32
19
3...

result:

wrong answer 1st numbers differ - expected: '71224', found: '23'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%