QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#167067 | #6520. Classic Problem | ucup-team134# | Compile Error | / | / | C++14 | 2.0kb | 2023-09-07 00:59:08 | 2023-09-07 00:59:08 |
Judging History
你现在查看的是最新测评结果
- [2023-12-06 00:08:28]
- hack成功,自动添加数据
- (//qoj.ac/hack/481)
- [2023-09-07 00:59:08]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-07 00:59:08]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
const int N=400050;
int p[N];
int Find(int x){return p[x]==x?x:p[x]=Find(p[x]);}
bool Union(int x,int y){
//printf("Union %i %i\n",x,y);
x=Find(x);
y=Find(y);
if(x==y)return false;
p[x]=y;
return true;
}
void Init(int n){
//printf("Init %i\n",n);
for(int i=1;i<=n;i++){
p[i]=i;
}
}
int main(){
int t;
scanf("%i",&t);
while(t--){
int n,m;
scanf("%i %i",&n,&m);
map<int,vector<int>> E;
vector<array<int,3>> edges;
for(int i=1;i<=m;i++){
int u,v,w;
scanf("%i %i %i",&u,&v,&w);
E[u].pb(v);
E[v].pb(u);
edges.pb({w,u,v});
}
vector<pair<int,int>> nodes;
ll ans=0;
int last=1;
for(auto it=E.begin();it!=E.end();it++){
if(it->first!=last){
nodes.pb({last,it->first-1});
ans+=nodes.back().second-nodes.back().first;
}
nodes.pb({it->first,it->first});
last=it->first+1;
}
if(last<=n){
nodes.pb({last,n});
ans+=n-last;
}
Init(nodes.size());
int SQ=min(100,sqrt(m)*2);
for(int i=1;i<=nodes.size();i++){
int L=nodes[i-1].first;
int R=nodes[i-1].second;
//printf("%i %i\n",L,R);
{
vector<int>& es=E[L];
sort(es.begin(),es.end());
int ptr=(int)es.size()-1;
int cnt=0;
for(int j=i-1;j>=1;j--){
int node=nodes[j-1].second;
while(ptr>=0 && es[ptr]>node)ptr--;
if(ptr==-1 || es[ptr]!=node){
edges.pb({L-node,i,j});
cnt++;
if(cnt>=SQ)break;
}
}
}
{
vector<int>&es=E[R];
sort(es.begin(),es.end());
int ptr=0;
int cnt=0;
for(int j=i+1;j<=nodes.size();j++){
int node=nodes[j-1].first;
while(ptr<es.size() && es[ptr]<node)ptr++;
if(ptr==es.size() || es[ptr]!=node){
edges.pb({node-R,i,j});
cnt++;
if(cnt>=SQ)break;
}
}
}
}
sort(edges.begin(),edges.end());
for(auto e:edges){
if(Union(e[1],e[2])){
ans+=e[0];
}
}
printf("%lld\n",ans);
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:55:27: error: no matching function for call to ‘min(int, __gnu_cxx::__enable_if<true, double>::__type)’ 55 | int SQ=min(100,sqrt(m)*2); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: answer.code:55:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__enable_if<true, double>::__type’ {aka ‘double’}) 55 | int SQ=min(100,sqrt(m)*2); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:278:5: note: template argument deduction/substitution failed: answer.code:55:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__enable_if<true, double>::__type’ {aka ‘double’}) 55 | int SQ=min(100,sqrt(m)*2); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)’ 3449 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3449:5: note: template argument deduction/substitution failed: answer.code:55:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 55 | int SQ=min(100,sqrt(m)*2); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3455 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3455:5: note: template argument deduction/substitution failed: answer.code:55:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 55 | int SQ=min(100,sqrt(m)*2); | ~~~^~~~~~~~~~~~~~~ answer.code:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%i",&t); | ~~~~~^~~~~~~~~ answer.code:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%i %i",&n,&m); | ~~~~~^~~~~~~~~~~~~~~ answer.code:34:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%i %i %i",&u,&v,&w); | ~~~~~^~~~~~~~~~~~~~~~~~~~~