답안 #406409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406409 2021-05-17T14:40:22 Z Fidisk Lasers (NOI19_lasers) C++14
100 / 100
380 ms 41348 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e15
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;

const ll base=361;
const ll mod=998244353;
const ld eps=1e-5;
const ll maxn=1e9+9;

ll n,m,sum,pre,i,j,k,a[500009],cnt,sl[500009],last,res;
vector<pll> q;

void update(ll l,ll r,ll gt) {
    q.push_back({l,gt});
    q.push_back({r+1,-gt});
}

ll calc(ll l,ll r) {
    return r-l+1;
}

int main(){
    IO;
    last=1;
    cin>>m>>n;
    for (i=1;i<=n;i++) {
        cin>>k;
        sum=0;
        pre=0;
        for (j=1;j<=k;j++) {
            cin>>a[j];
            sum+=a[j];
        }
        update(1,m-sum,i);
        for (j=1;j<=k;j++) {
            pre+=a[j];
            sum-=a[j];
            update(pre+1,m-sum,i);
        }
    }
    sort(q.begin(),q.end());
    for (i=0;i<q.size();i++) {
        //cout<<q[i].fi<<' '<<q[i].se<<'\n';
        if (q[i].se>0) {
            if (sl[q[i].se]==0) {
                cnt++;
            }
            sl[q[i].se]++;
        }
        else {
            sl[-q[i].se]--;
            if (sl[-q[i].se]==0) {
                cnt--;
            }
        }
        if (i+1<q.size()&&q[i+1].fi!=q[i].fi) {
            if (cnt==n) {
                res+=calc(last,q[i+1].fi-1);
               // cout<<"! "<<last<<' '<<q[i+1].fi-1<<'\n';
            }
            last=q[i+1].fi;
        }
    }
    if (cnt==n) {
        res+=calc(last,m);
        //cout<<"! "<<last<<' '<<m<<'\n';
    }
    //cout<<res<<'\n';
    cout<<m-res<<'\n';
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:60:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for (i=0;i<q.size();i++) {
      |              ~^~~~~~~~~
lasers.cpp:74:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         if (i+1<q.size()&&q[i+1].fi!=q[i].fi) {
      |             ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 284 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 284 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 307 ms 40648 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 371 ms 41348 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 18724 KB Output is correct
2 Correct 17 ms 5204 KB Output is correct
3 Correct 28 ms 5176 KB Output is correct
4 Correct 88 ms 18884 KB Output is correct
5 Correct 60 ms 9956 KB Output is correct
6 Correct 109 ms 20260 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 149 ms 19788 KB Output is correct
9 Correct 42 ms 9720 KB Output is correct
10 Correct 100 ms 19008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 18724 KB Output is correct
2 Correct 17 ms 5204 KB Output is correct
3 Correct 28 ms 5176 KB Output is correct
4 Correct 88 ms 18884 KB Output is correct
5 Correct 60 ms 9956 KB Output is correct
6 Correct 109 ms 20260 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 149 ms 19788 KB Output is correct
9 Correct 42 ms 9720 KB Output is correct
10 Correct 100 ms 19008 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 368 ms 39592 KB Output is correct
22 Correct 42 ms 5060 KB Output is correct
23 Correct 32 ms 5060 KB Output is correct
24 Correct 137 ms 18664 KB Output is correct
25 Correct 379 ms 39660 KB Output is correct
26 Correct 100 ms 18104 KB Output is correct
27 Correct 55 ms 4956 KB Output is correct
28 Correct 373 ms 39672 KB Output is correct
29 Correct 358 ms 39848 KB Output is correct
30 Correct 101 ms 18236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 284 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 307 ms 40648 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 371 ms 41348 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 85 ms 18724 KB Output is correct
22 Correct 17 ms 5204 KB Output is correct
23 Correct 28 ms 5176 KB Output is correct
24 Correct 88 ms 18884 KB Output is correct
25 Correct 60 ms 9956 KB Output is correct
26 Correct 109 ms 20260 KB Output is correct
27 Correct 2 ms 716 KB Output is correct
28 Correct 149 ms 19788 KB Output is correct
29 Correct 42 ms 9720 KB Output is correct
30 Correct 100 ms 19008 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 324 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 456 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 368 ms 39592 KB Output is correct
42 Correct 42 ms 5060 KB Output is correct
43 Correct 32 ms 5060 KB Output is correct
44 Correct 137 ms 18664 KB Output is correct
45 Correct 379 ms 39660 KB Output is correct
46 Correct 100 ms 18104 KB Output is correct
47 Correct 55 ms 4956 KB Output is correct
48 Correct 373 ms 39672 KB Output is correct
49 Correct 358 ms 39848 KB Output is correct
50 Correct 101 ms 18236 KB Output is correct
51 Correct 34 ms 5316 KB Output is correct
52 Correct 380 ms 40780 KB Output is correct
53 Correct 365 ms 40684 KB Output is correct
54 Correct 66 ms 9792 KB Output is correct
55 Correct 163 ms 18856 KB Output is correct
56 Correct 96 ms 19072 KB Output is correct
57 Correct 109 ms 18916 KB Output is correct
58 Correct 357 ms 41068 KB Output is correct
59 Correct 75 ms 9684 KB Output is correct
60 Correct 110 ms 18932 KB Output is correct