本蒟蒻写了个与正解相差十万八千里的贪心,得了80分
贪心代码(非正解):
#include <bits/stdc++.h>
using namespace std;
int n,m,vh[100010];
bool cmp(int a,int b){
return a>b;
}
int main(){
cin>>n>>m;
for(int i=1;i<=m;++i){
int x,y;
cin>>x>>y;
vh[x]++,vh[y]++;
}
sort(vh+1,vh+n+1,cmp);
int cnt=0,p=1;
while(cnt<m){
cnt+=vh[p];
p++;
}
cout<<p-1<<" "<<n-p+1<<endl;
return 0;
}
评测记录:
https://www.luogu.com.cn/record/189230447