QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198326#4246. Cactus is Moneyhotboy2703Compile Error//C++144.3kb2023-10-03 12:54:362023-10-03 12:54:36

Judging History

你现在查看的是最新测评结果

  • [2023-10-03 12:54:36]
  • 评测
  • [2023-10-03 12:54:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct pt{
    ll x,y;
    pt operator + (pt p) const{
        return {x+p.x, y+p.y};
    }
    pt operator - (pt p) const{
        return {x-p.x, y-p.y};
    }
    ll operator * (pt p)const{
        return x * p.y - y * p.x;
    }
};
ll sq(pt a,pt b){
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
void reorder_polygon(vector <pt> &p){
    ll pos = 0;
    for (ll i = 0;i < p.size();i ++){
        if (p[i].y < p[pos].y || (p[i].y == p[pos].y && p[i].x < p[pos].x)){
            pos = i;
        }
    }

    rotate(p.begin(),p.begin() + pos,p.end());
}
ll orientation(pt a, pt b, pt c){
    ll ori = (b-a)*(c-b);
    if (ori == 0)return 0;
    if (ori > 0)return 1;
    if (ori < 0)return -1;
}
vector <pt> sum(vector <pt> P,vector <pt> Q){
    //no mulipleple point counter clockwise
    reorder_polygon(P);
    reorder_polygon(Q);
    P.push_back(P[0]);
    P.push_back(P[1]);
    Q.push_back(Q[0]);
    Q.push_back(Q[1]);
    vector <pt> result;
    for (ll i = 1;i + 1 < P.size(); i++){
        assert(orientation(P[i-1],P[i],P[i+1]) == 1);
    }
    ll i,j;
    i = j = 0;
    while (i < P.size() - 2 || j < Q.size() - 2){
        result.push_back(P[i] + Q[j]);
        auto cross = (P[i+1] - P[i]) * (Q[j+1] - Q[j]);
        if (cross >= 0 && i < P.size() - 2){
            ++i;
        }
        if (cross <= 0 && j < Q.size() - 2){
            ++j;
        }
    }
    return result;
}
void convex_hull(vector <pt> &P){
    pt p0 = *min_element(P.begin(),P.end(),[=](pt a, pt b){return make_pair(a.y,a.x) < make_pair(b.y,b.x);});
    sort(P.begin(),P.end(),[&p0](const pt &a,const pt &b){
        auto o = orientation(p0,a,b);
        if (o == 0){
            return sq(p0,a) < sq(p0,b);
        }
        return (o == 1);
    });
    vector <pt> st;
    for (ll i = 0;i < P.size();i ++){
        while (st.size() > 1 && orientation(st[st.size() - 2],st[st.size() - 1],P[i]) == -1){
            st.pop_back();
        }
        st.push_back(P[i]);
    }
    P = st;
}
const ll MAXN = 5e4;
ll n,m;
vector <ll> g[MAXN + 100];
ll pa[MAXN + 100];
bool in[MAXN + 100];
struct edge{
    ll u,v,a,b;
};
ll depth[MAXN + 100];
edge all[MAXN * 5 + 100];
ll nxt(ll u, edge x){
    return (x.u == u?x.v:x.u);
}
vector <pt> tmp;
vector <vector <pt> > sex;
struct pq{
    vector <pt> a;
    bool operator < (const pq &p)const {
        return a.size() > p.a.size();
    }
};
priority_queue <pq> q;
void dfs(ll u){
    //cout<<u<<'\n';
    for (auto id:g[u]){
        auto v = nxt(u,all[id]);
        if (!in[v]){
            pa[v] = id;
            in[v] = 1;
            depth[v] = depth[u] + 1;
            //cout<<id<<' '<<u<<' '<<v<<'\n';
            dfs(v);
        }
        if (in[v]){
            if (depth[v] > depth[u] + 1){
                ll cur = v;
                tmp.clear();
                tmp.push_back({all[id].a,all[id].b});
                while (cur != u){
                    tmp.push_back({all[pa[cur]].a,all[pa[cur]].b});
                    cur = nxt(cur,all[pa[cur]]);
                }
                convex_hull(tmp);
                sex.push_back(tmp);
            }
        }
    }
}ll sum_a,sum_b;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);

    cin>>n>>m;
    sum_a = sum_b = 0;
    for (ll i = 1;i <= m;i ++){
        cin>>all[i].u>>all[i].v>>all[i].a>>all[i].b;
        g[all[i].u].push_back(i);
        g[all[i].v].push_back(i);
        sum_a += all[i].a;
        sum_b += all[i].b;
    }
    in[1] = 1;
    dfs(1);
    ll ans = sum_a * sum_b;

    for (auto x:sex){
        q.push({x});
    }
    while (q.size() > 1){
        auto u = q.top();
        q.pop();
        auto v = q.top();
        q.pop();
        auto tmp = sum(u.a,v.a);
        /*for (auto x:tmp){
            cout<<x.x<<' '<<x.y<<'\n';
        }*/
        q.push(tmp);
    }
    if (q.size()){

        vector <pt> minkowski = q.top().a;
        /*for (auto x:minkowski){
            cout<<x.x<<' '<<x.y<<'\n';
        }*/
        for (auto x:minkowski){
            ans = min(ans,(sum_a - x.x) * (sum_b - x.y));
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:155:15: error: no matching function for call to ‘std::priority_queue<pq>::push(std::vector<pt>&)’
  155 |         q.push(tmp);
      |         ~~~~~~^~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = pq; _Sequence = std::vector<pq, std::allocator<pq> >; _Compare = std::less<pq>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = pq]’
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from ‘std::vector<pt>’ to ‘const value_type&’ {aka ‘const pq&’}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:648:7: note: candidate: ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = pq; _Sequence = std::vector<pq, std::allocator<pq> >; _Compare = std::less<pq>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = pq]’
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from ‘std::vector<pt>’ to ‘std::priority_queue<pq>::value_type&&’ {aka ‘pq&&’}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
answer.code: In function ‘ll orientation(pt, pt, pt)’:
answer.code:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^