Cod sursa(job #1970589)

Utilizator pas.andreiPopovici Andrei-Sorin pas.andrei Data 19 aprilie 2017 14:29:47
Problema Marbles Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
#define pb push_back
#define NMAX 100005
#define ll long long
#define x first
#define y second
#define INF 0x3f3f3f3f
#define MOD 194767

using namespace std;

ifstream fin("fisier.in");
ofstream fout("fisier.out");

int fr[NMAX];

int main() {
    int n,m,i,x,y;
    ll ans=0;

	fin>>n>>m;
	for(i=1;i<=m;++i) {
		fin>>x>>y;
		if(x==1 || y==1 || x==n || y==n) {
			++fr[x];
			++fr[y];
		}
	}

	for(i=2;i<n;++i) ans+=n-fr[i]-2;

	fout<<ans/2;

    return 0;
}