Submission #1274542

#TimeUsernameProblemLanguageResultExecution timeMemory
1274542icebearFlooding Wall (BOI24_wall)C++20
Compilation error
0 ms0 KiB
// ~~ icebear ~~ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<int, ii> iii; template<class T> bool minimize(T &a, const T &b) { if (a > b) return a = b, true; return false; } template<class T> bool maximize(T &a, const T &b) { if (a < b) return a = b, true; return false; } #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORR(i,a,b) for(int i=(a); i>=(b); --i) #define REP(i, n) for(int i=0; i<(n); ++i) #define RED(i, n) for(int i=(n)-1; i>=0; --i) #define MASK(i) (1LL << (i)) #define BIT(S, i) (((S) >> (i)) & 1) #define mp make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define task "icebear" const int MOD = 1e9 + 7; const int inf = 1e9 + 27092008; const ll INF = 1e18 + 27092008; const int N = 5e5 + 5; int n, a[N], b[N]; vector<int> compress, pL, pR; vector<vector<int>> dpL, dpR; void init(void) { cin >> n; FOR(i, 1, n) cin >> a[i], compress.pb(a[i]); FOR(i, 1, n) cin >> b[i], compress.pb(b[i]); sort(all(compress)); compress.resize(unique(all(compress)) - compress.begin()); FOR(i, 1, n) a[i] = lower_bound(all(compress), a[i]) - compress.begin() + 1; FOR(i, 1, n) b[i] = lower_bound(all(compress), b[i]) - compress.begin() + 1; } void process(void) { int MAX = (int)compress.size(); if (n > 1e4) assert(MAX <= 2); dpL.resize(n + 5, vector<int>(MAX + 5, 0)); dpR.resize(n + 5, vector<int>(MAX + 5, 0)); pL.resize(n + 5, vector<int>(MAX + 5)); pR.resize(n + 5, vector<int>(MAX + 5)); dpL[0][0] = dpR[n + 1][0] = 1; FOR(i, 0, n - 1) FOR(j, 0, MAX) { (dpL[i + 1][max(a[i + 1], j)] += dpL[i][j]) %= MOD; (dpL[i + 1][max(b[i + 1], j)] += dpL[i][j]) %= MOD; } FORR(i, n + 1, 2) FOR(j, 0, MAX) { (dpR[i - 1][max(a[i - 1], j)] += dpR[i][j]) %= MOD; (dpR[i - 1][max(b[i - 1], j)] += dpR[i][j]) %= MOD; } int ans = 0; FOR(i, 2, n - 1) { FOR(j, 1, MAX) pL[j] = (pL[j - 1] + dpL[i - 1][j]) % MOD; FOR(j, 1, MAX) pR[j] = (pR[j - 1] + dpR[i + 1][j]) % MOD; FOR(j, 1, MAX) if (dpL[i - 1][j] > 0) { int v1 = max(0, compress[j - 1] - compress[a[i] - 1]); int v2 = max(0, compress[j - 1] - compress[b[i] - 1]); (ans += 1LL * (v1 + v2) * dpL[i - 1][j] % MOD * (pR[MAX] - pR[j - 1] + MOD) % MOD) %= MOD; } FOR(k, 1, MAX) if (dpR[i + 1][k] > 0) { int v1 = max(0, compress[k - 1] - compress[a[i] - 1]); int v2 = max(0, compress[k - 1] - compress[b[i] - 1]); (ans += 1LL * (v1 + v2) * dpR[i + 1][k] % MOD * (pL[MAX] - pL[k] + MOD) % MOD) %= MOD; } } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int tc = 1; // cin >> tc; while(tc--) { init(); process(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void process()':
Main.cpp:57:14: error: no matching function for call to 'std::vector<int>::resize(int, std::vector<int>)'
   57 |     pL.resize(n + 5, vector<int>(MAX + 5));
      |     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from Main.cpp:2:
/usr/include/c++/13/bits/stl_vector.h:1013:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]'
 1013 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_vector.h:1013:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/13/bits/stl_vector.h:1034:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int]'
 1034 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_vector.h:1034:54: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1034 |       resize(size_type __new_size, const value_type& __x)
      |                                    ~~~~~~~~~~~~~~~~~~^~~
Main.cpp:58:14: error: no matching function for call to 'std::vector<int>::resize(int, std::vector<int>)'
   58 |     pR.resize(n + 5, vector<int>(MAX + 5));
      |     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1013:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]'
 1013 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_vector.h:1013:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/13/bits/stl_vector.h:1034:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::resize(size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int]'
 1034 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_vector.h:1034:54: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1034 |       resize(size_type __new_size, const value_type& __x)
      |                                    ~~~~~~~~~~~~~~~~~~^~~
Main.cpp: In function 'int main()':
Main.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:95:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~