제출 #388867

#제출 시각아이디문제언어결과실행 시간메모리
388867KeshiAliens (IOI16_aliens)C++17
25 / 100
2081 ms23432 KiB
//In the name of God #include <bits/stdc++.h> #include "aliens.h" #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const ll maxn = 5e4 + 100; const ll maxk = 105; const ll mod = 1e9 + 7; const ll inf = 1e18; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() vector<pll> vec; ll ps[maxn]; vector<ll> dp[maxn]; void solve(ll k, ll l, ll r, ll s, ll e){ if(l >= r) return; ll mid = (l + r) >> 1; ll opt = s; dp[k][mid] = inf; for(ll i = s; i < e && i <= mid; i++){ ll x = dp[k - 1][i - 1] + (vec[mid].F - vec[i].S + 1) * (vec[mid].F - vec[i].S + 1) - ps[i]; if(x < dp[k][mid]){ dp[k][mid] = x; opt = i; } } solve(k, l, mid, s, e); solve(k, mid + 1, r, s, e); return; } long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { vector<pll> p(n); vec.pb(Mp(-1, -1)); for(ll i = 0; i < n; i++){ if(r[i] < c[i]) swap(r[i], c[i]); p[i] = Mp(c[i], -r[i]); } sort(all(p)); ll mx = -1; for(ll i = 0; i < n; i++){ p[i].S *= -1; if(p[i].S > mx){ vec.pb(Mp(p[i].S, p[i].F)); mx = p[i].S; } } n = Sz(vec) - 1; for(ll i = 2; i <= n; i++){ ll x = max(0ll, vec[i - 1].F - vec[i].S + 1); ps[i] = x * x; } k = min(k, n); for(ll i = 0; i <= k; i++){ dp[i].resize(n + 1, inf); } dp[0][0] = 0; for(ll i = 1; i <= k; i++){ solve(i, 1, n + 1, 1, n + 1); } return dp[k][n]; } /*int main(){ fast_io; return 0; }*/

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'void solve(ll, ll, ll, ll, ll)':
aliens.cpp:32:5: warning: variable 'opt' set but not used [-Wunused-but-set-variable]
   32 |  ll opt = s;
      |     ^~~
#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...