Submission #127302

#TimeUsernameProblemLanguageResultExecution timeMemory
127302roseanne_pcyPopeala (CEOI16_popeala)C++14
17 / 100
2048 ms9036 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 2e4+5; const int maxt = 55; ll pts[maxn]; int foo[maxt][maxn]; int n, t, s; struct segtree { ll st[4*maxn], lz[4*maxn]; void push(int p, int L, int R) { if(!lz[p]) return; st[p] += lz[p]; if(L != R) { lz[2*p] += lz[p]; lz[2*p+1] += lz[p]; } lz[p] = 0; } void update(int i, int j, int dx, int p = 1, int L = 0, int R = t) { push(p, L, R); if(i> R || j< L) return; if(i<= L && R<= j) { lz[p] += dx; push(p, L, R); return; } int M = (L+R)/2; update(i, j, dx, p<<1, L, M); update(i, j, dx, p<<1|1, M+1, R); st[p] = min(st[p<<1], st[p<<1|1]); } ll ask(int i, int j, int p = 1, int L = 0, int R = t) { if(i> R || j< L) return 1e9; push(p, L, R); if(i<= L && R<= j) return st[p]; int M = (L+R)/2; ll x = ask(i, j, p<<1, L, M); ll y = ask(i, j, p<<1|1, M+1, R); return min(x, y); } }; segtree ez[maxt]; ii rang[maxt]; ll dp[maxt][maxn]; int main() { scanf("%d %d %d", &n, &t, &s); for(int i = 1; i<= t; i++) scanf("%lld", &pts[i]); for(int i = 1; i<= n; i++) { char bar[maxn]; scanf("%s", bar+1); for(int j = 1; j<= t; j++) foo[i][j] = bar[j]-'0'; } for(int i = 1; i<= n; i++) rang[i] = {-1, -1}; ez[0].update(1, t, 1e9); for(int i = 1; i<= s; i++) ez[i].update(0, 0, 1e9); // printf("%lld\n", ez[1].ask(0, 0)); for(int i = 1; i<= t; i++) { // printf("i = %d\n", i); for(int j = 1; j<= n; j++) { if(foo[j][i]) { if(rang[j].X == -1) { rang[j] = {i, i}; } else rang[j].Y = i; // printf("update [%d..%d] +%lld\n", rang[j].X-1, i-1, pts[i]); for(int k = 0; k<= s; k++) ez[k].update(rang[j].X-1, i-1, pts[i]); } else { if(rang[j].X == -1) continue; else { for(int k = rang[j].X; k<= rang[j].Y; k++) { // printf("[%d..%d] -%lld\n", rang[j].X-1, k-1, pts[k]); for(int k2 = 0; k2<= s; k2++) ez[k2].update(rang[j].X-1, k-1, -pts[k]); } rang[j] = {-1, -1}; } } } for(int rem = 1; rem<= s; rem++) { dp[rem][i] = ez[rem-1].ask(0, i-1); // printf("kuydp[%d][%d] = %lld\n", rem, i, dp[rem][i]); ez[rem].update(i, i, dp[rem][i]); // printf("k\n"); } } for(int i = 1; i<= s; i++) printf("%lld\n", dp[i][t]); }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:68:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &t, &s);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:69:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= t; i++) scanf("%lld", &pts[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~
popeala.cpp:72:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char bar[maxn]; scanf("%s", bar+1);
                   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...