Submission #51855

#TimeUsernameProblemLanguageResultExecution timeMemory
51855zetapiAliens (IOI16_aliens)C++14
0 / 100
3 ms548 KiB
#include "aliens.h" #include "bits/stdc++.h" using namespace std; #define pb push_back #define mp make_pair #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e5; const long long INF=1e12; vector<pii> vec,lol; bool cmp(pii X,pii Y) { return X.second<Y.second; } long long cost(int X,int Y) { long long side=max(vec[X-1].second,vec[Y-1].second); side=max(side,(long long)vec[Y-1].first-vec[X-1].first+1); return side*side; } long long take_photos(int n=2, int m=6, int k=2, std::vector<int> r={1,4}, std::vector<int> c={4,1}) { long long N=n,M=m,K=k,dp[n+99][k+99]; for(int A=0;A<n;A++) lol.pb(mp(r[A],abs(r[A]-c[A])+1)); sort(lol.begin(),lol.end()); for(int A=0;A<lol.size();A++) { if(A+1<lol.size() and lol[A].first==lol[A+1].first) continue; vec.pb((lol[A])); } for(int A=0;A<=N;A++) for(int B=0;B<=K;B++) dp[A][B]=INF; dp[0][0]=0; for(int A=1;A<=vec.size();A++) { for(int B=0;B<A;B++) for(int C=1;C<=K;C++) dp[A][C]=min(dp[A][C],dp[B][C-1]+cost(B+1,A)); } long long res=INF; for(int A=1;A<=N;A++) for(int B=1;B<=K;B++) res=min(res,dp[A][B]); return res; } /*int main() { ios_base::sync_with_stdio(false); cout<<take_photos(); return 0; }*/

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=0;A<lol.size();A++)
              ~^~~~~~~~~~~
aliens.cpp:36:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(A+1<lol.size() and lol[A].first==lol[A+1].first)
      ~~~^~~~~~~~~~~
aliens.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=1;A<=vec.size();A++)
              ~^~~~~~~~~~~~
aliens.cpp:30:16: warning: unused variable 'M' [-Wunused-variable]
  long long N=n,M=m,K=k,dp[n+99][k+99];
                ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...