Submission #911879

#TimeUsernameProblemLanguageResultExecution timeMemory
911879Sir_Ahmed_ImranParachute rings (IOI12_rings)C++17
55 / 100
4026 ms165888 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define all(x) (x).begin(),(x).end() #define pii pair<int,int> #define MAXN 1000001 int n,x; int f[MAXN]; int par[MAXN]; vector<int> a[MAXN]; unordered_map<int,int> e,z,vis; void dfs(int v,int u,vector<int>& vec){ vis[v]=1; vec.append(v); for(auto& i:a[v]) if(!vis[i]) dfs(i,u,vec); if(vec.back()!=u) vec.pop_back(); } int root(int v){ if(par[v]==v) return v; par[v]=root(par[v]); return par[v]; } void join(int v,int u){ v=root(v); u=root(u); par[u]=v; f[v]+=f[u]; } bool same(int v,int u){ return (root(v)==root(u)); } void Init(int u){ n=x=u; for(int i=0;i<n;i++){ par[i]=i; e[i]=1; } } void Link(int v, int u){ if(!x) return; if(!f[root(v)] && same(v,u)){ vector<int> vec; dfs(v,u,vec); vis.clear(); x=0; for(auto& i:vec){ if(e[i]){ x++; z[i]=e[i]; } } swap(e,z); z.clear(); f[root(v)]==1; } a[v].append(u); a[u].append(v); join(v,u); if(a[v].size()>3){ x=e[v]; e.clear(); e[v]=x; } if(a[u].size()>3){ x=e[u]; e.clear(); e[u]=x; } if(a[v].size()==3){ x=0; if(e[v]){ x++; z[v]=e[v]; } for(auto& i:a[v]){ if(e[i]){ x++; z[i]=e[i]; } } swap(e,z); z.clear(); } if(a[u].size()==3){ x=0; if(e[u]){ x++; z[u]=e[u]; } for(auto& i:a[u]){ if(e[i]){ x++; z[i]=e[i]; } } swap(e,z); z.clear(); } } int CountCritical(){ return x;; }

Compilation message (stderr)

rings.cpp: In function 'void Link(int, int)':
rings.cpp:61:19: warning: value computed is not used [-Wunused-value]
   61 |         f[root(v)]==1;
      |         ~~~~~~~~~~^~~
#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...