제출 #1119381

#제출 시각아이디문제언어결과실행 시간메모리
1119381TrieTrFancy Fence (CEOI20_fancyfence)C++14
0 / 100
2 ms336 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;} template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;} const int N = 1e6 + 5; const int mod = 1e9 + 7; void add(int& x, int y) { if((x += y) >= mod) x -= mod; } int n, h[N], w[N], le[N], ri[N]; ll pf[N]; int main() { fastio; local(); cin >> n; for(int i = 1; i <= n; i++) cin >> h[i]; for(int i = 1 ;i <= n; i++) cin >> w[i], pf[i] = pf[i - 1] + w[i]; stack<int> st; for(int i = 1; i <= n; i++) { while(!st.empty() && h[st.top()] > h[i]) st.pop(); le[i] = st.empty() ? 0 : st.top(); st.emplace(i); } st = stack<int>(); for(int i = n; i > 0; i--) { while(!st.empty() && h[st.top()] >= h[i]) st.pop(); ri[i] = st.empty() ? n + 1 : st.top(); st.emplace(i); } int inv2 = 5e8 + 4; int res = 0; for(int i = 1; i <= n; i++) { ll len = pf[ri[i] - 1] - pf[le[i]]; int cur = 1ll * len * (len + 1) % mod * inv2 % mod * h[i] % mod; add(res, cur); } cout << res; }

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

fancyfence.cpp: In function 'void local()':
fancyfence.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...