Submission #591613

#TimeUsernameProblemLanguageResultExecution timeMemory
591613andrei_boacaPipes (CEOI15_pipes)C++14
40 / 100
4450 ms65536 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int n,m; vector<vector<unsigned short>> muchii; vector<vector<short>> bits; bool use[100005]; int par[100005]; int niv[100005],nivmin[100005]; void add(int a,int b) { if(muchii[a].size()%15==0) { short x=0; bits[a].push_back(x); } int val=bits[a].back(); if((b>>16)&1) { int nrbit=muchii[a].size()%15; val+=(1<<nrbit); bits[a].back()=val; b-=(1<<16); } muchii[a].push_back(b); } int getnum(int a,int poz) { int x=muchii[a][poz]; int grup=poz/15; int bit=poz%15; if((bits[a][grup]>>bit&1)) x+=(1<<16); return x; } void dfs(int nod) { use[nod]=1; nivmin[nod]=niv[nod]; for(int i=0;i<muchii[nod].size();i++) { int node=getnum(nod,i); if(node==par[nod]) continue; if(!use[node]) { par[node]=nod; niv[node]=niv[nod]+1; dfs(node); nivmin[nod]=min(nivmin[nod],nivmin[node]); } else nivmin[nod]=min(nivmin[nod],niv[node]); } int cnt=0; if(nivmin[nod]==niv[nod]&&par[nod]!=0) { for(int i=0;i<muchii[nod].size();i++) { int x=getnum(nod,i); if(x==par[nod]) cnt++; } if(cnt==1) cout<<par[nod]<<' '<<nod<<'\n'; } } int main() { cin>>n>>m; muchii.resize(n+1); bits.resize(n+1); for(int i=1;i<=m;i++) { int a,b; cin>>a>>b; add(b,a); add(a,b); } for(int i=1;i<=n;i++) if(!use[i]) { niv[i]=1; dfs(i); } return 0; }

Compilation message (stderr)

pipes.cpp: In function 'void dfs(int)':
pipes.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<short unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<muchii[nod].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~~~
pipes.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<short unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for(int i=0;i<muchii[nod].size();i++)
      |                     ~^~~~~~~~~~~~~~~~~~~
#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...
#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...