제출 #400218

#제출 시각아이디문제언어결과실행 시간메모리
400218rocks03Aliens (IOI16_aliens)C++14
12 / 100
290 ms352 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long take_photos(int N, int M, int K, vector<int> X, vector<int> Y){ vector<int> v[M]; rep(i, 0, N){ v[X[i]].pb(Y[i]); v[Y[i]].pb(X[i]); } vector<ll> dp(M + 1, LLONG_MAX), dp2(M + 1, LLONG_MAX); dp[M] = dp2[M] = 0; per(i, M, 0){ if(SZ(v[i])) break; dp[i] = 0; } rep(k, 1, K + 1){ per(i, M - 1, 0){ if(!SZ(v[i])){ dp2[i] = dp2[i + 1]; continue; } int l = 1; rep(j, i + 1, M + 1){ for(int x : v[j - 1]) l = max(l, x - i + 1); if(j - i >= l && dp[j] != LLONG_MAX){ ll cost = l; cost = cost * cost; dp2[i] = min(dp2[i], dp[j] + cost); } } } swap(dp, dp2); } return dp[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...
#Verdict Execution timeMemoryGrader output
Fetching results...