Submission #537349

#TimeUsernameProblemLanguageResultExecution timeMemory
537349pavementPopeala (CEOI16_popeala)C++17
0 / 100
538 ms1056 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif #define int long long #define mp make_pair #define mt make_tuple #define pb push_back #define ppb pop_back #define eb emplace_back #define g0(a) get<0>(a) #define g1(a) get<1>(a) #define g2(a) get<2>(a) #define g3(a) get<3>(a) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); using db = double; using ll = long long; using ld = long double; using ii = pair<int, int>; using iii = tuple<int, int, int>; using iiii = tuple<int, int, int, int>; template<class key, class value = null_type, class cmp = less<key> > using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>; int N, T, S, P[20005], lim[55], dp[20005], ndp[20005]; bool R[55][20005]; char C; vector<ii> vec; map<int, int> mpp; int qry(int l, int r, int x, int idx) { assert(l <= r); int ret = LLONG_MAX; for (int i = l; i <= r; i++) ret = min(ret, dp[i - 1] + x * P[idx] - x * P[i - 1]); return ret; } void go() { for (int i = 1; i <= T; i++) { mpp.clear(); vec.clear(); for (int k = 1; k <= N; k++) { if (R[k][i]) lim[k] = (lim[k] ? lim[k] : i); else lim[k] = 0; if (lim[k]) mpp[lim[k]]++; } for (auto k : mpp) vec.eb(k.first, k.second); if (vec.empty()) { ndp[i] = qry(1, i, 0, i); continue; } reverse(vec.begin(), vec.end()); int cum = 0; ndp[i] = LLONG_MAX; for (int k = 0, prv = i; k < vec.size(); k++) { cum += vec[k].second; //cout << "! " << vec[k].first << ' ' << prv << ' ' << cum << '\n'; ndp[i] = min(ndp[i], qry(vec[k].first, prv, cum, i)); prv = vec[k].first - 1; } if (vec.back().first != 1) { //cout << 1 << ' ' << vec.back().first - 1 << " 0\n"; ndp[i] = min(ndp[i], qry(1, vec.back().first - 1, 0, i)); } } } main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N >> T >> S; for (int i = 1; i <= T; i++) cin >> P[i], P[i] += P[i - 1]; for (int i = 1; i <= N; i++) for (int j = 1; j <= T; j++) { cin >> C; R[i][j] = (C == '1'); } dp[0] = 0; for (int i = 1; i <= T; i++) dp[i] = 1e16; for (int i = 1; i <= S; i++) { for (int j = 1; j <= N; j++) lim[j] = 0; go(); swap(dp, ndp); dp[0] = 1e16; cout << dp[T] << '\n'; } }

Compilation message (stderr)

popeala.cpp: In function 'void go()':
popeala.cpp:60:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   for (int k = 0, prv = i; k < vec.size(); k++) {
      |                            ~~^~~~~~~~~~~~
popeala.cpp: At global scope:
popeala.cpp:73:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   73 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...