답안 #425462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425462 2021-06-13T04:04:50 Z errorgorn Lasers (NOI19_lasers) C++17
87 / 100
587 ms 262148 KB
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <cstring>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
int l,r,total,run,lim;
bool st2=true; //its actually st1 and 2 but who cares
vector<int> v[500005];
vector<ii> range;
struct node{
    int s,e,m,len;
    bool blocked,split;
    node *l,*r;
    node(int _s,int _e){
        s=_s,e=_e,m=(s+e)>>1; //going to lazily build the ST
        blocked =false;
        split=false;
    }
    void update(int i,int j){
         if (i==s && j==e){
            blocked=true;
         }
         else{
            if (!split){
                split=true;
                l=new node(s,m);
                r=new node(m+1,e);
            }
            if (j<=m) l->update(i,j);
            else if (i>m) r->update(i,j);
            else l->update(i,m),r->update(m+1,j);
         }
    }
    int query(int i,int j){
        if (blocked) return e-s+1;
        else if (split) return l->query(i,m)+r->query(m+1,j);
        else return 0;
    }
}*root;
inline int read(){
    int x=0;
    char c=getchar_unlocked();
    while ('0'<=c && c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}
int main(){
    int a,b;
    //freopen("meow","r",stdin);
    l=read();
    r=read();
    root=new node(1,l);
    for (int x=0;x<r;x++){
        a=read();
        if (a!=1) st2=false;
        for (int y=0;y<a;y++){
            b=read();
            v[x].push_back(b);
        }
    }
    if (st2){
        int _max=0;
        for (int x=0;x<r;x++) _max=max(_max,v[x][0]);
        printf("%d\n",max(_max*2-l,0));
    }
    else {
        vector<ii>::iterator it;
        for (int x=0;x<r;x++){
            if (v[x].size()==0) continue;
            range.clear();
            total=0;
            run=0;
            for (vector<int>::iterator it=v[x].begin();it!=v[x].end();it++){
                total+=*it;
            }
            total=l-total;
            range.push_back(ii(1,total));
            for (vector<int>::iterator it=v[x].begin();it!=v[x].end();it++){
                run+=*it;
                range.push_back(ii(run+1,total));
            }
            int run=1;
            it=range.begin();
            while (run<=l){
                while (it!=range.end() && (*it).first<=run) run=max(run,(*it).first+(*it).second),it++;
                if (run<=l){
                    if (it!=range.end()) lim=( (*it).first);
                    else lim=l+1;
                    root->update(run,lim-1);
                    run=lim;
                }
            }
        }
        //for (auto i=s.begin();i!=s.end();i++) printf("%d ",*i);
        printf("%d\n",root->query(1,l));
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11980 KB Output is correct
2 Correct 7 ms 12004 KB Output is correct
3 Correct 9 ms 11976 KB Output is correct
4 Correct 10 ms 12020 KB Output is correct
5 Correct 8 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 9 ms 12024 KB Output is correct
8 Correct 9 ms 11960 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 11980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11980 KB Output is correct
2 Correct 7 ms 12004 KB Output is correct
3 Correct 9 ms 11976 KB Output is correct
4 Correct 10 ms 12020 KB Output is correct
5 Correct 8 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 9 ms 12024 KB Output is correct
8 Correct 9 ms 11960 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 11980 KB Output is correct
11 Correct 8 ms 11980 KB Output is correct
12 Correct 58 ms 33096 KB Output is correct
13 Correct 9 ms 12024 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 9 ms 11980 KB Output is correct
17 Correct 61 ms 33308 KB Output is correct
18 Correct 8 ms 11980 KB Output is correct
19 Correct 7 ms 11980 KB Output is correct
20 Correct 9 ms 12004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 67236 KB Output is correct
2 Correct 44 ms 31004 KB Output is correct
3 Correct 30 ms 25744 KB Output is correct
4 Correct 120 ms 68156 KB Output is correct
5 Correct 84 ms 47832 KB Output is correct
6 Correct 60 ms 43352 KB Output is correct
7 Correct 13 ms 15436 KB Output is correct
8 Correct 74 ms 45424 KB Output is correct
9 Correct 98 ms 57704 KB Output is correct
10 Correct 125 ms 73500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12108 KB Output is correct
2 Correct 8 ms 11980 KB Output is correct
3 Correct 8 ms 12020 KB Output is correct
4 Correct 8 ms 11980 KB Output is correct
5 Correct 8 ms 11980 KB Output is correct
6 Correct 8 ms 11980 KB Output is correct
7 Correct 10 ms 12056 KB Output is correct
8 Correct 8 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 12 ms 12088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 67236 KB Output is correct
2 Correct 44 ms 31004 KB Output is correct
3 Correct 30 ms 25744 KB Output is correct
4 Correct 120 ms 68156 KB Output is correct
5 Correct 84 ms 47832 KB Output is correct
6 Correct 60 ms 43352 KB Output is correct
7 Correct 13 ms 15436 KB Output is correct
8 Correct 74 ms 45424 KB Output is correct
9 Correct 98 ms 57704 KB Output is correct
10 Correct 125 ms 73500 KB Output is correct
11 Correct 9 ms 12108 KB Output is correct
12 Correct 8 ms 11980 KB Output is correct
13 Correct 8 ms 12020 KB Output is correct
14 Correct 8 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 8 ms 11980 KB Output is correct
17 Correct 10 ms 12056 KB Output is correct
18 Correct 8 ms 11980 KB Output is correct
19 Correct 8 ms 11980 KB Output is correct
20 Correct 12 ms 12088 KB Output is correct
21 Correct 63 ms 31756 KB Output is correct
22 Correct 104 ms 43452 KB Output is correct
23 Correct 64 ms 39452 KB Output is correct
24 Correct 146 ms 66712 KB Output is correct
25 Correct 58 ms 31744 KB Output is correct
26 Correct 239 ms 58200 KB Output is correct
27 Correct 103 ms 39984 KB Output is correct
28 Correct 57 ms 31812 KB Output is correct
29 Correct 59 ms 31784 KB Output is correct
30 Correct 131 ms 57380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 11980 KB Output is correct
2 Correct 7 ms 12004 KB Output is correct
3 Correct 9 ms 11976 KB Output is correct
4 Correct 10 ms 12020 KB Output is correct
5 Correct 8 ms 11980 KB Output is correct
6 Correct 9 ms 11980 KB Output is correct
7 Correct 9 ms 12024 KB Output is correct
8 Correct 9 ms 11960 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 8 ms 11980 KB Output is correct
11 Correct 8 ms 11980 KB Output is correct
12 Correct 58 ms 33096 KB Output is correct
13 Correct 9 ms 12024 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 9 ms 11980 KB Output is correct
17 Correct 61 ms 33308 KB Output is correct
18 Correct 8 ms 11980 KB Output is correct
19 Correct 7 ms 11980 KB Output is correct
20 Correct 9 ms 12004 KB Output is correct
21 Correct 109 ms 67236 KB Output is correct
22 Correct 44 ms 31004 KB Output is correct
23 Correct 30 ms 25744 KB Output is correct
24 Correct 120 ms 68156 KB Output is correct
25 Correct 84 ms 47832 KB Output is correct
26 Correct 60 ms 43352 KB Output is correct
27 Correct 13 ms 15436 KB Output is correct
28 Correct 74 ms 45424 KB Output is correct
29 Correct 98 ms 57704 KB Output is correct
30 Correct 125 ms 73500 KB Output is correct
31 Correct 9 ms 12108 KB Output is correct
32 Correct 8 ms 11980 KB Output is correct
33 Correct 8 ms 12020 KB Output is correct
34 Correct 8 ms 11980 KB Output is correct
35 Correct 8 ms 11980 KB Output is correct
36 Correct 8 ms 11980 KB Output is correct
37 Correct 10 ms 12056 KB Output is correct
38 Correct 8 ms 11980 KB Output is correct
39 Correct 8 ms 11980 KB Output is correct
40 Correct 12 ms 12088 KB Output is correct
41 Correct 63 ms 31756 KB Output is correct
42 Correct 104 ms 43452 KB Output is correct
43 Correct 64 ms 39452 KB Output is correct
44 Correct 146 ms 66712 KB Output is correct
45 Correct 58 ms 31744 KB Output is correct
46 Correct 239 ms 58200 KB Output is correct
47 Correct 103 ms 39984 KB Output is correct
48 Correct 57 ms 31812 KB Output is correct
49 Correct 59 ms 31784 KB Output is correct
50 Correct 131 ms 57380 KB Output is correct
51 Correct 225 ms 147356 KB Output is correct
52 Correct 70 ms 33040 KB Output is correct
53 Correct 64 ms 32964 KB Output is correct
54 Correct 367 ms 187524 KB Output is correct
55 Runtime error 587 ms 262148 KB Execution killed with signal 9
56 Halted 0 ms 0 KB -