Cod sursa(job #1259671)

Utilizator mirceadinoMircea Popoveniuc mirceadino Data 10 noiembrie 2014 13:00:21
Problema Count Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.94 kb
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
const string problemName = "count";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int NMAX = 30000 + 5;

int N, M, sol3, sol4;
unordered_set<int> V[NMAX];
PII sol;

int main() {
    int i, x, y;

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%d%d", &N, &M);

    for(i = 1; i <= M; i++) {
        scanf("%d%d", &x, &y);
        V[x].insert(y);
        V[y].insert(x);
    }

    for(x = 1; x <= N; x++) {
        for(auto y : V[x]) {
            if(y <= x)
                continue;
            for(auto z : V[x]) {
                if(z <= y || !V[y].count(z))
                    continue;
                sol3++;
                for(auto t : V[x]) {
                    if(t <= z || !V[y].count(t) || !V[x].count(t))
                        continue;
                    sol4++;
                }
            }
        }
    }

    sol = make_pair(1, N);

    if(M)
        sol = make_pair(2, M);

    if(sol3)
        sol = make_pair(3, sol3);

    if(sol4)
        sol = make_pair(4, sol4);

    printf("%d %d\n", sol.first, sol.second);

    return 0;
}