# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
399773 | Dremix10 | Aliens (IOI16_aliens) | C++17 | 2083 ms | 292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#ifdef dremix
#define p(x) cerr<<#x<<" = "<<x<<endl;
#define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
#define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
#define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
#define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
#define p(x) {}
#define p2(x,y) {}
#define pp(x) {}
#define pv(x) {}
#define ppv(x) {}
#endif
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 2e18;
const int MOD = 1e9+7;
const int N = 3e5+1;
bool v[100];
int cnt;
vector<pi> arr;
int maxi;
int m;
int solve(int k){
if(sz(arr) == cnt)
return 0;
if(k == maxi)
return MOD;
int i,j,ii,jj;
int best = MOD;
for(i=0;i<m;i++){
/// point i,i start
for(j=i;j<m;j++){
/// point j,j end
int cost = (j-i+1)*(j-i+1);
vector<int> used;
for(ii=0;ii<sz(arr);ii++){
if(v[ii])continue;
if(i<=arr[ii].F && arr[ii].F<=j &&
i<=arr[ii].S && arr[ii].S<=j){
v[ii] = true;
used.push_back(ii);
cnt++;
}
}
best = min(best,solve(k+1) + cost);
for(auto x : used){
v[x] = false;
cnt--;
}
}
}
return best;
}
long long take_photos(int n, int mm, int k, vector<int> r, vector<int> c) {
int i,j;
maxi = k;
m = mm;
for(i=0;i<n;i++){
arr.push_back({r[i],c[i]});
}
return solve(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |