제출 #1272676

#제출 시각아이디문제언어결과실행 시간메모리
1272676kl0989eAliens (IOI16_aliens)C++20
60 / 100
1374 ms1062152 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define vi vector<int> #define vl vector<ll> #define pi pair<int, int> #define pl pair<ll,ll> #define all(x) (x).begin(),(x).end() struct cht { vector<pl> stk; int pt=0; void add(ll a, ll b) { while (stk.size()>1 && (1.0*stk[stk.size()-2].se-b)/(a-stk[stk.size()-2].fi) <= (1.0*stk.back().se-stk[stk.size()-2].se)/(stk[stk.size()-2].fi-stk.back().fi)) { stk.pop_back(); } stk.pb({a,b}); if (pt>=stk.size()) { pt=stk.size()-1; } } ll get(ll x) { while (pt<stk.size()-1 && ((__int128_t)(x)*stk[pt].fi+stk[pt].se)>=((__int128_t)(x)*stk[pt+1].fi+stk[pt+1].se)) { pt++; } return x*stk[pt].fi+stk[pt].se; } }; long long take_photos(int n, int m, int k, vi r, vi c) { vector<pl> tpo(n); vl pmx(n); for (int i=0; i<n; i++) { tpo[i].fi=min(r[i],c[i]); tpo[i].se=max(r[i],c[i]); } sort(all(tpo)); vector<pl> po={tpo[0]}; for (int i=0; i<n; i++) { if (po.back().fi==tpo[i].fi) { po.back().se=tpo[i].se; } else if (po.back().se<tpo[i].se) { po.pb(tpo[i]); } } n=po.size(); vector<cht> chts(k+1); for (int i=0; i<k; i++) { chts[i].add(2*(1-po[0].fi),(1-po[0].fi)*(1-po[0].fi)); } vector<vl> dp(n+1,vl(k+1,2e12)); dp[0][0]=0; for (int i=1; i<=n; i++) { for (int j=k; j>=1; j--) { dp[i][j]=min(dp[i][j],po[i-1].se*po[i-1].se+chts[j-1].get(po[i-1].se)); ll sub=0; if (i!=n && po[i-1].se>=po[i].fi) { sub=(po[i-1].se-po[i].fi+1)*(po[i-1].se-po[i].fi+1); } if (i!=n) { chts[j].add(2*(1-po[i].fi),dp[i][j]-sub+(1-po[i].fi)*(1-po[i].fi)); } /* ll mx=po[i-1].se; for (int i2=i-1; i2>=0; i2--) { ll sub=0; if (i2>0 && po[i2-1].se>=po[i2].fi) { sub=(po[i2-1].se-po[i2].fi+1)*(po[i2-1].se-po[i2].fi+1); } dp[i][j]=min(dp[i][j],dp[i2][j-1]+(mx-po[i2].fi+1)*(mx-po[i2].fi+1)-sub); // b = dp[i2][j-1]-sub+(1-po[i2].fi)*(1-po[i2].fi) // a = 2(1-po[i2].fi) }*/ } } return *min_element(all(dp[n])); }

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

aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...