Submission #823449

#TimeUsernameProblemLanguageResultExecution timeMemory
823449merlinAliens (IOI16_aliens)C++14
0 / 100
1 ms468 KiB
#include<bits/stdc++.h> #include "aliens.h" using namespace std; #define ll long long #define f first #define s second void setIO(string name="") { cin.tie(0)->sync_with_stdio(0); if (!name.empty()) { freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } void set_min(ll &a,ll b){ a = min(a,b); } /* ll take_photos(int n,int m,int K,vector<int> r,vector<int> c){ vector<int> poradie(n); iota(poradie.begin(),poradie.end(),0); sort(poradie.begin(),poradie.end(),[&r] (int a,int b){return r[a] < r[b];}); ll DP[n+1][K+1]; for(int i = 0;i<n;i++)for(int k = 0;k<K+1;k++){ DP[i][k] = 1e18; } for(int i = 0;i<=K;i++) DP[0][i] = 0; for(int i = 1;i<=n;i++)for(int k = 0;k < K;k++){ for(int j = 0;j<i;j++){ set_min(DP[i][k],DP[j][k+1] + pow((ll) r[poradie[i-1]] - r[poradie[j]] + 1,2)); } //cerr<<i<<" "<<k<<" "<<DP[i][k]<<endl; } ll ans = 1e18; for(int i = 0;i<=K;i++) ans = min(ans,DP[n][i]); return ans; } */ ll DP[510][510]; ll take_photos(int n,int m,int K,vector<int> r,vector<int> c){ set<pair<ll,ll>> a; for(int i = 0;i<n;i++){ a.insert({r[i],c[i]}); assert(r[i] == c[i]); } vector<ll> R; for(auto i : a) R.push_back(i.f); int N = a.size(); for(int i = 0;i<N+1;i++)for(int j = 0;j<K+1;j++)DP[i][j] = 1e18; for(int i = 0;i<=K;i++) DP[0][i] = 0; for(int i = 1;i<=n;i++)for(int k = 1;k <= K;k++){ for(int j = 0;j<i;j++){ set_min(DP[i][k],DP[j][k-1] + (R[i-1] - R[j] + 1)*(R[i-1] - R[j] + 1)); } //cerr<<i<<" "<<k<<" "<<DP[i][k]<<endl; } ll ans = 1e18; for(int i = 0;i<=K;i++) ans = min(ans,DP[n][i]); return ans; }

Compilation message (stderr)

aliens.cpp: In function 'void setIO(std::string)':
aliens.cpp:11:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   freopen((name+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:12:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   freopen((name+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...