제출 #1041457

#제출 시각아이디문제언어결과실행 시간메모리
1041457hotboy2703조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
0 / 100
8 ms476 KiB
#include<bits/stdc++.h> using ll = long long; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) const ll INF = 1e18; const ll MAXN = 50; bool edge[MAXN][MAXN]; int main(){ ios_base::sync_with_stdio(0);cin.tie(nullptr); ll n,m; cin>>n>>m; ll ans = 0; for (ll j = 1;j <= m;j ++){ ll x,y; cin>>x>>y; if (edge[x][y] == 0){ edge[x][y] = 1; ans++; while (1){ ll pre_ans = ans; for (ll x = 1;x <= n;x ++){ for (ll y = 1;y <= n;y ++){ if (edge[x][y]){ for (ll z = 1;z <= n;z ++){ if (edge[y][z] && edge[z][y] && z != x){ if (!edge[x][z]){ edge[x][z] = 1; ans++; } } } } } } if (ans==pre_ans)break; } } cout<<ans<<'\n'; } // dnc(0,n,all); // for (ll i = 1;i <= cnt;i ++)cout<<ans[i].fi<<' '<<ans[i].se<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...