Language: C++

#include<bits/stdc++.h> #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-funroll-loops") #pragma GCC target("avx,sse4") #define mms(a,n) memset(a,0,sizeof((a)[0])*(n)) #define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n)) #define lowbit(x) ((x)&-(x)) #define pb push_back #define fi first #define se second #define debug(...) fprintf(stderr,__VA_ARGS__) #define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++) #define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--) #define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d) #define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++) #define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--) #define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d) #define Clear(a) memset(a,0,sizeof(a)) #define Copy(a,b) memcpy(a,b,sizeof(b)) #define ALL(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ldb; typedef double db; typedef pair<int,int> pi; const int N=100005; int n,m,a[N],fa[N],blk; vector<int>e[N],E; ll ans; int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);} int main(){ scanf("%d%d",&n,&m); fo(i,1,n)scanf("%d",&a[i]),fa[i]=i,blk++; for(int i=1,u,v;i<=m;i++){ scanf("%d%d",&u,&v);u++;v++; if(find(u)!=find(v))fa[find(u)]=find(v),blk--; } fo(i,1,n)e[find(i)].pb(a[i]); if(blk==1)puts("0"),exit(0); int cur=blk-2; fo(i,1,n)if(e[i].size()){ sort(ALL(e[i])); ans+=e[i][0]; fo(j,1,int(e[i].size())-1)E.pb(e[i][j]); } sort(ALL(E)); if(cur>E.size())puts("Impossible"),exit(0); fo(i,0,cur-1)ans+=E[i]; cout<<ans<<endl; return 0; }
--------------------- 
作者：whzzt 
来源：CSDN 
原文：https://blog.csdn.net/whzzt/article/details/79321484 
版权声明：本文为博主原创文章，转载请附上博文链接！

Compiler output:
a.cc:1:25: warning: extra tokens at end of #include directive
    1 | #include<bits/stdc++.h> #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-funroll-loops") #pragma GCC target("avx,sse4") #define mms(a,n) memset(a,0,sizeof((a)[0])*(n)) #define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n)) #define lowbit(x) ((x)&-(x)) #define pb push_back #define fi first #define se second #define debug(...) fprintf(stderr,__VA_ARGS__) #define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++) #define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--) #define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d) #define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++) #define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--) #define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d) #define Clear(a) memset(a,0,sizeof(a)) #define Copy(a,b) memcpy(a,b,sizeof(b)) #define ALL(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ldb; typedef double db; typedef pair<int,int> pi; const int N=100005; int n,m,a[N],fa[N],blk; vector<int>e[N],E; ll ans; int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);} int main(){ scanf("%d%d",&n,&m); fo(i,1,n)scanf("%d",&a[i]),fa[i]=i,blk++; for(int i=1,u,v;i<=m;i++){ scanf("%d%d",&u,&v);u++;v++; if(find(u)!=find(v))fa[find(u)]=find(v),blk--; } fo(i,1,n)e[find(i)].pb(a[i]); if(blk==1)puts("0"),exit(0); int cur=blk-2; fo(i,1,n)if(e[i].size()){ sort(ALL(e[i])); ans+=e[i][0]; fo(j,1,int(e[i].size())-1)E.pb(e[i][j]); } sort(ALL(E)); if(cur>E.size())puts("Impossible"),exit(0); fo(i,0,cur-1)ans+=E[i]; cout<<ans<<endl; return 0; }
      |                         ^
a.cc:1:355: warning: __VA_ARGS__ can only appear in the expansion of a C++11 variadic macro
    1 | #include<bits/stdc++.h> #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-funroll-loops") #pragma GCC target("avx,sse4") #define mms(a,n) memset(a,0,sizeof((a)[0])*(n)) #define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n)) #define lowbit(x) ((x)&-(x)) #define pb push_back #define fi first #define se second #define debug(...) fprintf(stderr,__VA_ARGS__) #define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++) #define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--) #define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d) #define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++) #define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--) #define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d) #define Clear(a) memset(a,0,sizeof(a)) #define Copy(a,b) memcpy(a,b,sizeof(b)) #define ALL(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ldb; typedef double db; typedef pair<int,int> pi; const int N=100005; int n,m,a[N],fa[N],blk; vector<int>e[N],E; ll ans; int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);} int main(){ scanf("%d%d",&n,&m); fo(i,1,n)scanf("%d",&a[i]),fa[i]=i,blk++; for(int i=1,u,v;i<=m;i++){ scanf("%d%d",&u,&v);u++;v++; if(find(u)!=find(v))fa[find(u)]=find(v),blk--; } fo(i,1,n)e[find(i)].pb(a[i]); if(blk==1)puts("0"),exit(0); int cur=blk-2; fo(i,1,n)if(e[i].size()){ sort(ALL(e[i])); ans+=e[i][0]; fo(j,1,int(e[i].size())-1)E.pb(e[i][j]); } sort(ALL(E)); if(cur>E.size())puts("Impossible"),exit(0); fo(i,0,cur-1)ans+=E[i]; cout<<ans<<endl; return 0; }
      |                                                                                                                                                                                                                                                                                                                                                                   ^
a.cc:1:1: error: expected unqualified-id before '--' token
    1 | #include<bits/stdc++.h> #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-funroll-loops") #pragma GCC target("avx,sse4") #define mms(a,n) memset(a,0,sizeof((a)[0])*(n)) #define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n)) #define lowbit(x) ((x)&-(x)) #define pb push_back #define fi first #define se second #define debug(...) fprintf(stderr,__VA_ARGS__) #define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++) #define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--) #define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d) #define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++) #define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--) #define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d) #define Clear(a) memset(a,0,sizeof(a)) #define Copy(a,b) memcpy(a,b,sizeof(b)) #define ALL(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ldb; typedef double db; typedef pair<int,int> pi; const int N=100005; int n,m,a[N],fa[N],blk; vector<int>e[N],E; ll ans; int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);} int main(){ scanf("%d%d",&n,&m); fo(i,1,n)scanf("%d",&a[i]),fa[i]=i,blk++; for(int i=1,u,v;i<=m;i++){ scanf("%d%d",&u,&v);u++;v++; if(find(u)!=find(v))fa[find(u)]=find(v),blk--; } fo(i,1,n)e[find(i)].pb(a[i]); if(blk==1)puts("0"),exit(0); int cur=blk-2; fo(i,1,n)if(e[i].size()){ sort(ALL(e[i])); ans+=e[i][0]; fo(j,1,int(e[i].size())-1)E.pb(e[i][j]); } sort(ALL(E)); if(cur>E.size())puts("Impossible"),exit(0); fo(i,0,cur-1)ans+=E[i]; cout<<ans<<endl; return 0; }
      | ^~