Submission #1116436

#TimeUsernameProblemLanguageResultExecution timeMemory
1116436jamesbamberFancy Fence (CEOI20_fancyfence)C++17
Compilation error
0 ms0 KiB
#include <vector> #include <stack> #include <cassert> #include <iostream> using namespace std; constexpr int MOD = 1e9+7; int main(){ int N; cin >> N; vector<int> L(N), W(N); for(int &x: L) cin >> x; for(int &x: W) cin >> x; L.resize(N+2); W.resize(N+2); for(int i=N; i>0; i--) L[i] = L[i-1]; L[0] = 0; for(int i=N; i>0; i--) W[i] = W[i-1]; W[0] = 0; N+=2; vector<int> pf(N+1); for(int i=0; i<N; i++) pf[i+1] = (pf[i] + W[i])%MOD; auto count_rect = [&](long long l_high, long long l_low, long long w){ long long l = l_high - l_low; return ((w*(w+1)/2)%MOD) * ((l*(l+1)/2)%MOD + l*l_low%MOD)%MOD; }; long long ans = 0; stack<int> st; for(int i=0; i<N; i++){ while(st.size() and L[st.top()] >= L[i]){ int j = st.top(); st.pop(); if(j == 0) break; int l2 = L[j]; int l1 = max(L[i], L[st.top()]); int w = (pf[i] - pf[st.top()+1] + MOD)%MOD; ans += count_rect(l2, l1, w); ans %= MOD; } st.push(i); } assert(st.size() == 1); cout ans; }

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:17:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   17 |     for(int i=N; i>0; i--) L[i] = L[i-1]; L[0] = 0;
      |     ^~~
fancyfence.cpp:17:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   17 |     for(int i=N; i>0; i--) L[i] = L[i-1]; L[0] = 0;
      |                                           ^
fancyfence.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for(int i=N; i>0; i--) W[i] = W[i-1]; W[0] = 0;
      |     ^~~
fancyfence.cpp:18:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   18 |     for(int i=N; i>0; i--) W[i] = W[i-1]; W[0] = 0;
      |                                           ^
fancyfence.cpp:47:9: error: expected ';' before 'ans'
   47 |     cout ans;
      |         ^~~~
      |         ;
fancyfence.cpp:47:5: warning: statement has no effect [-Wunused-value]
   47 |     cout ans;
      |     ^~~~