제출 #437613

#제출 시각아이디문제언어결과실행 시간메모리
437613shahriarkhanFancy Fence (CEOI20_fancyfence)C++14
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std ; const long long mod = 1e9 + 7 ; int main() { int n ; scanf("%d",&n) ; long long h[n+1] = {0} , w[n+1] = {0} , dp[n+1][2] , ans = 0 ; for(int i = 1 ; i <= n ; ++i) scanf("%lld",&h[i]) ; for(int i = 1 ; i <= n ; ++i) scanf("%lld",&w[i]) ; for(int i = 0 ; i <= n ; ++i) { dp[i][1] = 0 , dp[i][2] = 0 ; } for(int i = 1 ; i <= n ; ++i) { for(int j = 1 ; j <= h[i] ; ++j) { dp[i][j] = (dp[i-1][j] + w[i])%mod ; } if(h[i-1]==2) { ans = (ans + (dp[i-1][2]*(dp[i-1][2]+1))%mod)%mod ; } } ans = (ans + ((dp[n][1]*(dp[n][1]+1))/2)%mod)%mod ; if(h[n]==2) ans = (ans + (dp[n][2]*(dp[n][2]+1))%mod)%mod ; printf("%lld\n",ans) ; return 0 ; }

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

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
fancyfence.cpp:11:40: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i = 1 ; i <= n ; ++i) scanf("%lld",&h[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~~~
fancyfence.cpp:12:40: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i = 1 ; i <= n ; ++i) scanf("%lld",&w[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~~~
fancyfence.cpp:15:31: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   15 |         dp[i][1] = 0 , dp[i][2] = 0 ;
      |                        ~~~~~~~^
fancyfence.cpp:25:36: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   25 |             ans = (ans + (dp[i-1][2]*(dp[i-1][2]+1))%mod)%mod ;
      |                           ~~~~~~~~~^
fancyfence.cpp:29:38: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   29 |     if(h[n]==2) ans = (ans + (dp[n][2]*(dp[n][2]+1))%mod)%mod ;
      |                               ~~~~~~~^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...