Submission #1073168

#TimeUsernameProblemLanguageResultExecution timeMemory
1073168huyngodzzNetwork (BOI15_net)C++14
0 / 100
1 ms6748 KiB
///huynhocute123/// #include<bits/stdc++.h> using namespace std; #define S second #define F first #define pii pair<int,int> #define piii pair<int,pair<int,int>> #define pb push_back #define pi M_PI #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define REP(i, a, b) for(int i = b; i >= a; --i) #define ALL(v) v.begin(),v.end() #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin); #define out(name) if(fopen(name, "w")) freopen(name, "w", stdout); //random_device rd; //mt19937 rng(rd()); //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long const int maxN = 1e5 ; const int modd = 1e9 + 7; const int base = 2309; const int MAX = 1e9+9; void minimize(int &u, int v){ if(v < u) u = v; } void maximize(int &u, int v){ if(v > u) u = v; } int n, k, t, m, res, a[maxN], low[maxN], nu[maxN], cnt, ck[maxN]; int l, r; bool vis[maxN]; vector<int> e[maxN], adj[maxN]; vector<pii> bri; void dfs(int u,int p ){ nu[u] = low[u]= ++cnt; for(auto x : e[u]){ if(x == p)continue; if(nu[x]){ minimize(low[u], nu[x]); }else{ dfs(x, u); minimize(low[u], low[x]); if(low[x] == nu[x]){ adj[u].pb(x); adj[x].pb(u); ck[x] =1; ck[u] =1; } } } } void dfs2(int u ,int p){ int ct = 0; // cout << u << " "; for(auto x : adj[u]){ if(x == p)continue; vis[x] =1; // cout << x << " "; ct=1; dfs2(x, u); // maximize(k, max(ct- 1, 1)) } // cout <<ct; if(ct == 0)++k; } void solve(){ cin >> n >> m; FOR(i ,1 , m){ cin >> l >> r; e[l].pb(r); e[r].pb(l); } FOR(i, 1, n){ if(!nu[i])dfs(i,0); } FOR(i ,1 , n){ if(!vis[i] && ck[i] ==1 ){ k =0; vis[i] =1; dfs2(i, 0); if(adj[i].size() == 1)k++; // cout << k << " "; res += (k + 1 )/2; // res +=k; } } cout <<res; // for(auto [x,y] : bri){ // cout << x << " " << y <<'\n'; // } // cout << bri.size(); } signed main(){ // freopen("name.inp","r",stdin); // freopen("name.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(0); inp("task.inp"); t = 1; // cin >> t; while( t-- )solve(); }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
net.cpp:102:5: note: in expansion of macro 'inp'
  102 |     inp("task.inp");
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...