#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define all(x) x.begin(), x.end()
#define TASK "nonsense"
/// end of template ///
const int N = 1e3 + 10;
int n,m;
bool adj[N][N];
void solve()
{
cin>>n>>m;
for(int i=1;i<=m;++i)
{
int x,y; cin>>x>>y;
adj[x][y]=1;
}
int ans=m;
while(1)
{
int old=ans;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j) for(int k=j+1;k<=n;++k) if(j!=i && k!=i && adj[i][j] && adj[i][k])
{
ans+=((adj[j][k]==0)+(adj[k][j]==0));
adj[j][k]=adj[k][j]=1;
}
}
if(ans==old) break;
}
cout<<ans;
// cerr<<ans<<'\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
int testcase=1;
// cin>>testcase;
while (testcase--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |