Submission #1232929

#TimeUsernameProblemLanguageResultExecution timeMemory
1232929Tenis0206Amusement Park (CEOI19_amusementpark)C++20
42 / 100
3093 ms227676 KiB
#include <bits/stdc++.h>

using namespace std;

const int Mod = 998244353;
const int inv = 499122177;
const int nmax = 18;

int n, m;

pair<int,int> e[nmax * nmax + 5];

int poz[nmax + 5];

map<long long, bool> sel;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifdef home
    freopen("nr.in","r",stdin);
    freopen("nr.out","w",stdout);
#endif // home
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>e[i].first>>e[i].second;
    }
    for(int i=1; i<=n; i++)
    {
        poz[i] = i;
    }
    long long rez = 0;
    do
    {
        long long mask = 0;
        for(int i=1; i<=m; i++)
        {
            if(poz[e[i].first] > poz[e[i].second])
            {
                mask += (1LL << (i - 1));
            }
        }
        rez += (!sel[mask]);
        sel[mask] = true;
    }
    while(next_permutation(poz + 1, poz + n + 1));
    rez = 1LL * rez * m / 2;
    rez %= Mod;
    cout<<rez<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...