제출 #1167798

#제출 시각아이디문제언어결과실행 시간메모리
1167798mychecksedadAliens (IOI16_aliens)C++20
컴파일 에러
0 ms0 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include"aliens.h" using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 2e5+100, M = 1e5+10, K = 105, MX = 30; const ll INF = 1e18; struct P{ ll m, b, idx; ll eval(ll x){ return x*m + b; } }; double intersection(P x, P y){ return (x.b - y.b) / (y.m - x.m); } struct CH{ vector<P> C; void insert(ll c, ll m, int idx){ P x = {m, c, idx}; if(C.size() && C.back().m == x.m && C.back().b < x.b) return; while(C.size() && C.back().m == x.m && C.back().b >= x.b) C.pop_back(); while(C.size() > 1 && (x.eval(intersection(C.back(), C[int(C.size())-2])) <= C.back().eval(intersection(C.back(), C[int(C.size())-2])))) C.pop_back(); C.pb(x); } P get(ll fi){ if(C.size() == 1) return C[0]; P RES = C[0]; int l = 1, r = int(C.size()) - 1; while(l <= r){ int m = l+r>>1; double pos = intersection(C[m-1], C[m]); if(fi <= pos){ if(RES.eval(fi) > C[m-1].eval(fi)) RES = C[m-1]; r = m - 1; }else{ if(RES.eval(fi) > C[m].eval(fi)) RES = C[m]; l = m + 1; } } for(int j = max(l-4, 0); j < min(int(C.size()), r+4);++j){ if(RES.eval(fi) > C[j].eval(fi)) RES = C[j]; } return RES; } }; int n, m, k; array<ll, 2> a[N]; ll dp[N][K], go[N]; CH cht[K]; ll take_photos(int nn, int mm, int kk, vector<int> r, vi c){ n=nn,m=mm,k=kk; vector<ll> val; for(int i=0;i<n;++i){ a[i][0]=r[i],a[i][1]=c[i]; } /*void solve(){ cin >> n >> m >> k; for(int i = 0; i < n; ++i) cin >> a[i][0] >> a[i][1]; */ for(int i = 0; i < n; ++i){ if(a[i][0] > a[i][1]){ swap(a[i][0], a[i][1]); } val.pb(a[i][0]), val.pb(a[i][1]); } val.pb(0); sort(all(val)); val.erase(unique(all(val), val.end()); sort(a, a+n, [&](const array<ll,2> &x, const array<ll, 2> &y){ return array<ll,2>{x[1],x[0]}<array<ll,2>{y[1],y[0]}; }); //for(int i = 0; i < n; ++i) cout << a[i][0] << ' ' << a[i][1] << '\n'; ll mn = MOD; int ptr = n - 1; m = int(val.size()) - 1; for(int i = m; i >= 0; --i){ while(ptr >= 0 && a[ptr][1] >= val[i]){ mn = min(mn, a[ptr][0]); --ptr; } go[i] = mn; } //for(int j = 0; j <= m; ++j) cout << go[j] << ' '; en; for(int j = 0; j <= k; ++j){ for(int i = 0; i <= m; ++i) dp[i][j] = INF; } cht[0].insert(0, 0, 0); ll ans = INF; for(int j = 1; j <= k; ++j){ for(ll i = 0; i <= m; ++i){ auto p = cht[j-1].get(val[i]); dp[i][j] = p.eval(i) + val[i] * val[i]; ll best = go[p.idx]; //cout << i << ' ' << j << ' ' << dp[i][j] << ' ' << best << ' '; if(go[i] == MOD) ans=min(ans,dp[i][j]); best = max(best, (go[i])); if(j < k && go[i] < val[i]){ dp[i][j] -= (best - val[i]) * (best - val[i]); dp[i][j] += go[i] * go[i]; cht[j].insert(dp[i][j], -2*go[i], i); }else if(j < k){ dp[i][j] += go[i] * go[i]; cht[j].insert(dp[i][j], -2*go[i], i); } //cout << i << ' ' << j << ' ' << dp[i][j] << '\n'; } } for(int i = 0; i <= m; ++i) if(go[i] == MOD) ans = min(ans, dp[i][k]); //cout << ans; return ans; } /* int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; } */

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

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:83:40: error: expected ')' before ';' token
   83 |   val.erase(unique(all(val), val.end());
      |            ~                           ^
      |                                        )
In file included from /usr/include/c++/11/bits/stl_algobase.h:71,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from aliens.cpp:2:
/usr/include/c++/11/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Iterator2 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >]':
/usr/include/c++/11/bits/stl_algo.h:931:20:   required from 'constexpr _ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _BinaryPredicate = __gnu_cxx::__ops::_Iter_comp_iter<__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> > >]'
/usr/include/c++/11/bits/stl_algo.h:995:27:   required from 'constexpr _FIter std::unique(_FIter, _FIter, _BinaryPredicate) [with _FIter = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _BinaryPredicate = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >]'
aliens.cpp:83:19:   required from here
/usr/include/c++/11/bits/predefined_ops.h:158:30: error: no match for call to '(__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >) (long long int&, long long int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
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
      |         ^~~~