QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788525#9623. 合成大西瓜Lonelyper#Compile Error//C++171.6kb2024-11-27 17:18:482024-11-27 17:18:48

Judging History

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

  • [2024-11-27 17:18:48]
  • 评测
  • [2024-11-27 17:18:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
void print(vector<int> nums)
{
    for(int x:nums)
    cout<<x<<" ";
    cout<<endl;
}
static cal3(vector<int> nums)
{
    sort(nums.begin(),nums.end());
    return nums[1];
}
class meth
{
    public:
    int n;
    vector<vector<int>> edges;
    //vector<int> leaf;
    vector<int> lock;
    vector<int> mark;
    vector<int> status;
    vector<int> nums;
    meth(int sz,vector<vector<int>> raw_edges,vector<int> o_nums):edges(sz),mark(sz,0),status(sz,0),lock(sz,0)
    {
        n=sz;
        nums=o_nums;
        for(auto arr:raw_edges)
        {
        edges[arr[0]].push_back(arr[1]);
        edges[arr[1]].push_back(arr[0]);
        ++lock[arr[0]];
        ++lock[arr[1]];
        }
    }
    int cal()
    {
        int maxv=0;
        for(int i=0;i<n;++i)
        {
            if(lock[i]==1)
            continue;
            maxv=max(maxv,nums[i]);
        }
        return maxv;
    }

};
void Lonelyper(){
    int n,m;
    cin>>n>>m;
    vector<int> weight(n);
    for(auto&x:weight)
    cin>>x;
    vector<vector<int>> raw_edges(m,vector<int>(2));    
    for(auto&arr:raw_edges)
    {
    cin>>arr[0]>>arr[1];
    --arr[0];
    --arr[1];
    }
    if(n==1)
    {
        cout<<weight[0]<<endl;
        return;
    }
    meth *test=new meth(n,raw_edges,weight);
    int ans=test->cal();
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t --) Lonelyper();
    return 0;
}

详细

answer.code:9:8: error: ISO C++ forbids declaration of ‘cal3’ with no type [-fpermissive]
    9 | static cal3(vector<int> nums)
      |        ^~~~