Submission #618900

#TimeUsernameProblemLanguageResultExecution timeMemory
618900errorgornMaking Friends on Joitter is Fun (JOI20_joitter2)C++17
1 / 100
5005 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int,int> #define fi first #define se second #define endl '\n' #define puf push_front #define pof pop_front #define pub push_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--) #define all(x) (x).begin(),(x).end() #define sz(x) (int) (x).size() mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); int n,m; bool has[55][55]; signed main(){ cin.tie(0); cout.tie(0); cin.sync_with_stdio(false); cin>>n>>m; int a,b; int ans=0; while (m--){ cin>>a>>b; if (!has[a][b]){ has[a][b]=true; ans++; while (true){ bool done=true; rep(x,1,n+1) rep(y,1,n+1) rep(z,1,n+1) if (x!=z){ if (has[x][y] && has[y][z] && has[z][y] && !has[x][z]){ has[x][z]=true; ans++; done=false; } } if (done) break; } } cout<<ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...