Submission #125275

#TimeUsernameProblemLanguageResultExecution timeMemory
125275wilwxkCoin Collecting (JOI19_ho_t4)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=2e3+5; const ll INF=1e15+9; vector<pair<ll, ll> > v[2]; ll dp[MAXN][MAXN]; int n; ll dist(int a, int b, ll x) { if(b>=v[a].size()) return INF; ll resp=0; auto ponto=v[a][b]; resp+=llabs(ponto.first-x); resp+=min(llabs(ponto.second-2), abs(llponto.second-1)); return resp; } ll fazdp(int a, int b) { if(a==v[0].size()&&b==v[1].size()) return 0; if(a>v[0].size()||b>v[1].size()) return INF; if(dp[a][b]!=-1) return dp[a][b]; // printf("calc %d %d\n", a, b); ll ind=(a+b)/2+1; dp[a][b]=INF; ll &cur=dp[a][b]; cur=min(cur, fazdp(a+2, b)+dist(0, a, ind)+dist(0, a+1, ind)+1); cur=min(cur, fazdp(a, b+2)+dist(1, b, ind)+dist(1, b+1, ind)+1); cur=min(cur, fazdp(a+1, b+1)+dist(0, a, ind)+dist(1, b, ind)); // printf("%d %d >> %lld\n", a, b, cur); return cur; } int main() { scanf("%d", &n); n*=2; memset(dp, -1, sizeof(dp)); for(int i=1; i<=n; i++) { int a, b; scanf("%d %d", &a, &b); if(b>=2) v[0].push_back({a, b}); else v[1].push_back({a, b}); } sort(v[0].begin(), v[0].end()); sort(v[1].begin(), v[1].end()); ll respf=fazdp(0, 0); printf("%lld\n", respf); }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'll dist(int, int, ll)':
joi2019_ho_t4.cpp:12:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(b>=v[a].size()) return INF;
     ~^~~~~~~~~~~~~
joi2019_ho_t4.cpp:16:39: error: 'llponto' was not declared in this scope
  resp+=min(llabs(ponto.second-2), abs(llponto.second-1));
                                       ^~~~~~~
joi2019_ho_t4.cpp:16:39: note: suggested alternative: 'ponto'
  resp+=min(llabs(ponto.second-2), abs(llponto.second-1));
                                       ^~~~~~~
                                       ponto
joi2019_ho_t4.cpp: In function 'll fazdp(int, int)':
joi2019_ho_t4.cpp:21:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(a==v[0].size()&&b==v[1].size()) return 0;
     ~^~~~~~~~~~~~~
joi2019_ho_t4.cpp:21:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(a==v[0].size()&&b==v[1].size()) return 0;
                     ~^~~~~~~~~~~~~
joi2019_ho_t4.cpp:22:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(a>v[0].size()||b>v[1].size()) return INF;
     ~^~~~~~~~~~~~
joi2019_ho_t4.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(a>v[0].size()||b>v[1].size()) return INF;
                    ~^~~~~~~~~~~~
joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n); n*=2;
  ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~