제출 #226465

#제출 시각아이디문제언어결과실행 시간메모리
226465thebesCollecting Stamps 3 (JOI20_ho_t3)C++14
100 / 100
236 ms134988 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MN = 202; int N, L, i, arr[MN], t[MN]; ll nxt, d, td, k, dis[2][MN][MN][MN]; struct idk{int l, r, k, p;}; bitset<MN> vs[2][MN][MN], st[2][MN][MN]; queue<idk> q; int main(){ for(scanf("%d%d",&N,&L),i=1;i<=N;i++) scanf("%d",&arr[i]); for(i=1;i<=N;i++) scanf("%d",&t[i]); arr[0]=0; t[0]=-1; q.push({0,0,0,0}); memset(dis,0x3f,sizeof(dis)); dis[0][0][0][0]=0; while(q.size()){ idk cur=q.front(); q.pop(); vs[cur.p][cur.l][cur.r][cur.k]=1; st[cur.p][cur.l][cur.r][cur.k]=0; ll T = dis[cur.p][cur.l][cur.r][cur.k]; if((cur.r+1)%(N+1)==cur.l%(N+1)){ continue; // cannot expand further } nxt=cur.r+1; if(nxt>N) nxt=0; d=arr[nxt]-arr[cur.r]; if(d<0) d+=L; if(!cur.p) td=arr[cur.r]-arr[cur.l]; else td=0; if(td<0) td+=L; d+=td; if(T+d<=t[nxt]) k=cur.k+1; else k=cur.k; if(T+d<dis[1][cur.l][nxt][k]){ dis[1][cur.l][nxt][k]=T+d; if(!st[1][cur.l][nxt][k]){ q.push({cur.l,nxt,k,1}); st[1][cur.l][nxt][k]=1; } } nxt=cur.l-1; if(nxt<0) nxt=N; d=arr[cur.l]-arr[nxt]; if(d<0) d+=L; if(cur.p) td=arr[cur.r]-arr[cur.l]; else td=0; if(td<0) td+=L; d+=td; if(T+d<=t[nxt]) k=cur.k+1; else k=cur.k; if(T+d<dis[0][nxt][cur.r][k]){ dis[0][nxt][cur.r][k]=T+d; if(!st[0][nxt][cur.r][k]){ q.push({nxt,cur.r,k,0}); st[0][nxt][cur.r][k]=1; } } } int ans=0; for(i=0;i<=N;i++){ for(int j=0;j<=N;j++){ for(int k=0;k<=N;k++){ if(dis[0][i][j][k]<(1LL<<60)||dis[1][i][j][k]<(1LL<<60)) ans=max(ans,k); } } } printf("%d\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:43:39: warning: narrowing conversion of 'nxt' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
                 q.push({cur.l,nxt,k,1});
                                       ^
ho_t3.cpp:43:39: warning: narrowing conversion of 'k' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
ho_t3.cpp:60:39: warning: narrowing conversion of 'nxt' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
                 q.push({nxt,cur.r,k,0});
                                       ^
ho_t3.cpp:60:39: warning: narrowing conversion of 'k' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
ho_t3.cpp:14:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d%d",&N,&L),i=1;i<=N;i++)
         ~~~~~~~~~~~~~~~~~~~^~~~
ho_t3.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&t[i]);
         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...