답안 #1007900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007900 2024-06-25T17:32:44 Z christinelynn Lasers (NOI19_lasers) C++17
45 / 100
87 ms 44600 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define freeopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 998244353
#define pb push_back
#define mk make_pair
#define ll long long
#define foor(x,vec) for(auto x:vec ){cout<<x<<" ";}
#define fi first
#define se second
#define MAXN 500069
#define lld long double
#define cha ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ffl fflush(stdout)
#define sst string
#define pii pair<ll,ll>
ll mvx[]={0,0,-1,1};
ll mvy[]={1,-1,0,0};
ll n,q;

ll k[MAXN];
vector<ll> b[MAXN];
ll vis[MAXN];
ll ps[MAXN],sf[MAXN];
void solve(){
    cin>>n>>q;
    REP(i,0,q-1){
        cin>>k[i];
        REP(j,0,k[i]-1){
            ll x;
            cin>>x;
            b[i].pb(x);
        }
    }
    ll ans=0;
    vector <pair<ll,ll>> vec;
    REP(i,0,q-1){
        REP(j,0,k[i]){
            ps[j]=0;
            sf[j]=0;
        }
        for(ll j=0;j<k[i];j++){
            ps[j]=ps[j-1]+b[i][j];
        }
        for(ll j=k[i]-1;j>=0;j--){
            sf[j]=sf[j+1]+b[i][j];
        }
       
        REP(j,0,k[i]-1){
            ll r=n-sf[j+1];
            ll l=ps[j-1];
            if(j-1<0)l=0;
            ll len=r-l+1;
            if(len-2*(len-b[i][j])>0){
                ll nl=r-b[i][j]+1;
                ll nr=l+b[i][j];
                nl=max(nl,(ll)1);
                nr=min(nr,(n));
                if(nl<=nr)
                vec.pb({nl,nr});
            }
                
        }
    }
    sort(vec.begin(),vec.end());
    ll i=0;
    while(i<vec.size()){
        ll ln=vec[i].fi;
        ll rn=vec[i].se;
        ll idx=i+1;
        while(idx<vec.size()){
            if(vec[idx].fi<=rn){
                rn=max(rn,vec[idx].se);
                idx++;
            }
            else{
                break;
            }
        }
        ans+=max((rn-ln+1),(ll)0);
        i=idx;
    }
    cout<<ans<<endl;
}
int main(){
    cha
    ll tc=1;
//    cin>>tc;
    while(tc--){
        solve();
    }
}

Compilation message

lasers.cpp: In function 'void solve()':
lasers.cpp:69:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     while(i<vec.size()){
      |           ~^~~~~~~~~~~
lasers.cpp:73:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         while(idx<vec.size()){
      |               ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Correct 2 ms 16732 KB Output is correct
6 Correct 3 ms 16728 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 2 ms 16732 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Correct 2 ms 16732 KB Output is correct
6 Correct 3 ms 16728 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 2 ms 16732 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 79 ms 44600 KB Output is correct
13 Correct 2 ms 16728 KB Output is correct
14 Correct 2 ms 16732 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 2 ms 16728 KB Output is correct
17 Correct 87 ms 40904 KB Output is correct
18 Correct 2 ms 16732 KB Output is correct
19 Correct 2 ms 16732 KB Output is correct
20 Correct 2 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 27796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Correct 2 ms 16732 KB Output is correct
6 Correct 2 ms 16732 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 2 ms 16732 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 2 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 27796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Correct 2 ms 16732 KB Output is correct
6 Correct 3 ms 16728 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 2 ms 16732 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 79 ms 44600 KB Output is correct
13 Correct 2 ms 16728 KB Output is correct
14 Correct 2 ms 16732 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 2 ms 16728 KB Output is correct
17 Correct 87 ms 40904 KB Output is correct
18 Correct 2 ms 16732 KB Output is correct
19 Correct 2 ms 16732 KB Output is correct
20 Correct 2 ms 16732 KB Output is correct
21 Incorrect 28 ms 27796 KB Output isn't correct
22 Halted 0 ms 0 KB -