제출 #173692

#제출 시각아이디문제언어결과실행 시간메모리
173692red1108Aliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include<ext/rope> using namespace std; using namespace __gnu_cxx; #define fi first #define se second #define fastio ios_base::sync_with_stdio(false);cin.tie(0) #define fopen freopen("input.txt", "r", stdin) #define pb push_back #define prec(a) cout<<fixed;cout.precision(a); #define all(a) (a).begin(), (a).end() typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef tuple<int,int,int> tiii; const ll INF = 1e18; const int inf = 2e9; template<class T> void pr(T t) {cout << t << " ";} template<class T, class ...Args> void pr(T a, Args ...args) {cout << a << " ";pr(args...);} template<class ...Args> void prl(Args ...args) {pr(args...);cout << endl;} ll dp[101010]; vector<pll> tmp, p; int cur=0; struct Line{ ll a, b; int cnt; Line(){} Line(ll aa, ll bb, int cc){a=aa;b=bb;cnt=cc;} }; vector<Line> line; double cross(Line A, Line B){ return (double)(B.b-A.b)/(double)(A.a-B.a); } pll get(ll x){ while(cur+1<line.size()&&cross(line[cur],line[cur+1])<=(double)x) cur++; //printf("why?? %d\n", cur); //for(auto i:line) printf("deug (%lld,%lld)\n", i.a,i.b); if(cur>=line.size()) return pll(0,0); return pll(line[cur].a*x+line[cur].b,line[cur].cnt); } void add(Line nl){ while(line.size()>=2&&cross(line[line.size()-2],line[line.size()-1])>=cross(line[line.size()-2],nl)) line.pop_back(); line.push_back(nl); } int get_take(ll c){ //dp초기화 cur=0; line.clear(); add(Line(-4*(p[1].fi-1),c+2LL*(p[1].fi-1)*(p[1].fi-1),1)); pll t; for(int i=1;i<(int)p.size();i++){ if(i>1){ if(p[i].fi<=p[i-1].se) add(Line(-4*(p[i].fi-1),c+t.fi+2LL*(p[i].fi-1)*(p[i].fi-1) - 2LL*(p[i-1].se-p[i].fi+1)*(p[i-1].se-p[i].fi+1),t.se+1)); else add(Line(-4*(p[i].fi-1),c+t.fi+2LL*(p[i].fi-1)*(p[i].fi-1),t.se+1)); } t = get(p[i].se); t.fi+=2LL*p[i].se*p[i].se; dp[i]=t.fi; } return (int)t.se; } ll take_photos(int n, int m, int k, vector<int>x, vector<int>y){ k=min(n,k); for(int i=0;i<n;i++){ if(x[i]>y[i]) swap(x[i], y[i]); tmp.pb({x[i],y[i]}); } sort(tmp.begin(), tmp.end(), [](pii a, pii b){if(a.se==b.se) return a.fi>b.fi;return a.se<b.se;}); p.pb({-1,-1}); for(auto i:tmp){ while(!p.empty()&&p[p.size()-1].fi>=i.fi) p.pop_back(); p.pb(i); } k=min(k,(int)p.size()-1); ll s = 0,e=2*(ll)m*m; ll t = INF; while(s<e){ ll mid = (s+e)/2; if(get_take(mid*2+1)<=k) e = mid; else s = mid+1; } int num = get_take(s*2); return dp[p.size()-1]/2-s*num; } int main(){ int n, m, k; int inx[100010], iny[100010]; cin>>n>>m>>k; vector<int> x,y; for(int i=0;i<n;i++){ int a; cin>>a; x.pb(a); } for(int i=0;i<n;i++){ int a; cin>>a; y.pb(a); } printf("%lld\n",take_photos(n,m,k,x,y)); }

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

aliens.cpp: In function 'pll get(ll)':
aliens.cpp:40:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(cur+1<line.size()&&cross(line[cur],line[cur+1])<=(double)x) cur++;
        ~~~~~^~~~~~~~~~~~
aliens.cpp:43:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(cur>=line.size()) return pll(0,0);
     ~~~^~~~~~~~~~~~~
aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:81:5: warning: unused variable 't' [-Wunused-variable]
  ll t = INF;
     ^
aliens.cpp: In function 'int main()':
aliens.cpp:92:6: warning: unused variable 'inx' [-Wunused-variable]
  int inx[100010], iny[100010];
      ^~~
aliens.cpp:92:19: warning: unused variable 'iny' [-Wunused-variable]
  int inx[100010], iny[100010];
                   ^~~
/tmp/ccaputbt.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccXJJLgP.o:aliens.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status