Submission #583331

#TimeUsernameProblemLanguageResultExecution timeMemory
583331Koosha_mvBodyguard (JOI21_bodyguard)C++14
0 / 100
2025 ms1460896 KiB
#include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=12020,M=6060; ll n,q,T[N],A[N],B[N],C[N],dp[N][M],nxt[N][M],prv[N][M]; int32_t main(){ ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0); cin>>n>>q; f(i,0,n){ cin>>T[i]>>A[i]>>B[i]>>C[i]; T[i]<<=1; A[i]<<=1; B[i]<<=1; C[i]>>=1; if(A[i]<B[i]){ f(pos,A[i],B[i]){ maxm(nxt[T[i]+pos-A[i]][pos],C[i]); } } else{ f_(pos,A[i],B[i]+1){ maxm(prv[T[i]+A[i]-pos][pos],C[i]); } } } f_(i,N-2,1){ f(j,1,N-2){ dp[i][j]=max(dp[i+1][j+1]+nxt[i][j],dp[i+1][j-1]+prv[i][j]); } } while(q--){ int p,x; cin>>p>>x; cout<<dp[p<<1][x<<1]<<'\n'; } } /* 3 1 3 1 5 2 1 4 1 4 4 2 4 4 2 2 2 1 1 2 1 4 3 1 3 2 3 3 */

Compilation message (stderr)

bodyguard.cpp: In function 'int32_t main()':
bodyguard.cpp:49:12: warning: iteration 6059 invokes undefined behavior [-Waggressive-loop-optimizations]
   49 |    dp[i][j]=max(dp[i+1][j+1]+nxt[i][j],dp[i+1][j-1]+prv[i][j]);
      |    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bodyguard.cpp:8:31: note: within this loop
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   48 |   f(j,1,N-2){
      |     ~~~~~~~                    
bodyguard.cpp:48:3: note: in expansion of macro 'f'
   48 |   f(j,1,N-2){
      |   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...