Submission #1111125

#TimeUsernameProblemLanguageResultExecution timeMemory
1111125modwweŠarenlist (COCI22_sarenlist)C++17
110 / 110
9 ms592 KiB
#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC optimize("conserve-stack") #include<bits/stdc++.h> #define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define mask(k) (1<<k) #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf = 1e14; const int mod2 = 1e9 + 7; const int mod1 = 998244353; const ll base=67; int add(int x,int y) { if(x+y>=mod2) x-=mod2; if(x+y<0) x+=mod2; return x+y; } struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a, b, c; }; struct id { int a, b, c, d; }; struct ie { int a, b, c, d, e; }; ll n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center; int i, s10, s12,k1,k2,k3,s11,t,lim,w,l,r; int kk; int el = 19; main() { if(fopen(task".inp","r")) { fin(task); // fou(task); } NHP /// cin>>s1; // modwwe phongbeo(),down // checktime } int in[61]; int ou[61]; vector<int> v[61]; int a[16]; int b[16]; int f[61]; int par[61]; void dfs(int x,int y) { in[x]=++dem; par[x]=y; for(auto f:v[x]) if(f!=y) dfs(f,x); ou[x]=dem; } bool check(int x,int y) { if(in[x]<=in[y]&&in[y]<=ou[x]) return 1; return 0; } struct dsconcu { ib dsu[61]; void rest() { for(int i=1; i<=n; i++) dsu[i]= {1,i}; dem=n-1; } int get(int x) { if(dsu[x].b!=x)return dsu[x].b=get(dsu[x].b); return x; } void noi(int x,int y) { if(x==0||y==0) return; x=get(x); y=get(y); if(x==y) return; dem--; if(dsu[x].a<dsu[y].a) swap(x,y); dsu[x].a+=dsu[y].a; dsu[y].b=x; } }ds; void skibidi(int x,int y) { s4=0; while(!check(x,y)) { s4=x; if(!check(par[x],y)) ds.noi(x,par[x]); x=par[x]; } s5=0; while(y!=x) { s5=y; if(par[y]!=x) ds.noi(y,par[y]); y=par[y]; } ds.noi(s4,s5); } void phongbeo() { cin>>n>>m>>k; f[0]=1; for(int i=1; i<=n; i++) f[i]=f[i-1]*k%mod2; for(int i=1; i<n; i++) cin>>l>>r,v[l].pb(r),v[r].pb(l); dfs(1,0); for(int i=1; i<=m; i++) cin>>a[i]>>b[i]; s6=0; for(int i=0;i<(1<<m);i++) { ds.rest(); for(int j=0;j<m;j++) if(bit(i,j)) { skibidi(a[j+1],b[j+1]); } int total=1; if(sobit(i)%2==1)total=-1; s6=add(s6,f[dem]*total); } cout<<s6; }

Compilation message (stderr)

Main.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main()
      | ^~~~
Main.cpp: In member function 'void dsconcu::rest()':
Main.cpp:96:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   96 |         for(int i=1; i<=n; i++)
      |         ^~~
Main.cpp:98:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   98 |             dem=n-1;
      |             ^~~
Main.cpp: In function 'void phongbeo()':
Main.cpp:146:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  146 |     for(int i=1; i<=m; i++)
      |     ^~~
Main.cpp:148:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  148 |         s6=0;
      |         ^~
Main.cpp: In function 'int main()':
Main.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:61:9: note: in expansion of macro 'fin'
   61 |         fin(task);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...