Submission #283357

#TimeUsernameProblemLanguageResultExecution timeMemory
283357davi_bartWiring (IOI17_wiring)C++14
7 / 100
1108 ms262148 KiB
#include <bits/stdc++.h> #include <wiring.h> using namespace std; #define ll long long //#define int ll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> x, y; map<int,bool> vis[100010]; map<int,ll> memo[100010]; ll sol(int a,int b){ if(a==x.size() && b==y.size())return 0; if(vis[a][b])return memo[a][b]; vis[a][b]=1; ll best=1e16; best=min(best,sol(a+1,b+1)+abs(x[a]-y[b])); if(a>0 && x[a]-y[b]>y[b]-x[a-1])best=min(best,sol(a,b+1)+abs(x[a-1]-y[b])); if(b>0 && y[b]-x[a]>x[a]-y[b-1])best=min(best,sol(a+1,b)+abs(x[a]-y[b-1])); return memo[a][b]=best; } //vector<pair<int,int> >x; long long min_total_length(std::vector<int> r, std::vector<int> b) { x=r;y=b; ll t=0; for(int i=y.size()-1;i>=0;i--){ t+=abs(y[i]-x.back()); vis[x.size()][i]=1; memo[x.size()][i]=t; } t=0; for(int i=x.size()-1;i>=0;i--){ t+=abs(x[i]-y.back()); vis[i][y.size()]=1; memo[i][y.size()]=t; } return sol(0,0); /*for(int a:r)x.push_back({a,1}); for(int a:b)x.push_back({a,0}); sort(x.begin(),x.end()); ll tota=0,totb=0,aa=0,bb=0; for(auto k:x){ if(k.second){ aa=0; bb++; }else{ bb=0; aa++; } tota+=aa; totb+=bb; } return max(tota,totb);*/ }

Compilation message (stderr)

wiring.cpp: In function 'long long int sol(int, int)':
wiring.cpp:11:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   if(a==x.size() && b==y.size())return 0;
      |      ~^~~~~~~~~~
wiring.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   if(a==x.size() && b==y.size())return 0;
      |                     ~^~~~~~~~~~
#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...