[Offer收割]编程练习赛96 register

Ended

Participants:98

Verdict:Runtime Error
Score:0 / 100
Submitted:2019-03-17 14:10:40

Lang:G++

Edit
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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1000000+10;
int n,m,ans[maxn],block,num,l[maxn],r[maxn],lazy[maxn],belong[maxn];
void build(){
    block=sqrt(n);
    num=n/block;
    if(n%block)num++;
    for(int i=1;i<=num;i++){
        l[i]=(i-1)*block+1,r[i]=i*block;
    }
    r[num]=n;
    for(int i=1;i<=n;i++)
    belong[i]=(i-1)/block+1;
}
void update(int x,int y){
    if(belong[x]==belong[y]){
        for(int i=x;i<=y;i++)ans[i]++;
        return;
    }
    for(int i=x;i<=r[belong[x]];i++)ans[i]++;
    for(int i=belong[x]+1;i<belong[y];i++)lazy[i]++;
    for(int i=l[belong[y]];i<=y;i++)ans[i]++;
}
int main(){
    while(~scanf("%d%d",&n,&m)){
        memset(lazy,0,sizeof(lazy));
        memset(ans,0,sizeof(ans));
        if(m==1){
            int x; scanf("%d",&x);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX