# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
919911 | CyberCow | Amusement Park (CEOI19_amusementpark) | C++17 | 3026 ms | 171124 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const ll N = 20;
vector<pair<int,int>> v[N];
int tex[N];
int uxx[N][N];
ll mod = 998244353;
void solve()
{
int n, i, j, m, x, y;
cin >> n >> m;
for ( i = 0; i < m; i++)
{
cin >> x >> y;
v[x].push_back({ y, i });
v[y].push_back({ x, i });
uxx[x][y] = 1;
}
vector<int> pereb;
for ( i = 1; i <= n; i++)
{
pereb.push_back(i);
}
set<ll> ka;
ll ans = 0;
int bj = 1;
do
{
//cout << bj++ << ' ';
for ( i = 0; i < pereb.size(); i++)
{
tex[pereb[i]] = i;
}
ll gum = 0, pox = 0;
for ( i = 0; i < pereb.size(); i++)
{
for (auto to : v[pereb[i]])
{
if ((tex[pereb[i]] > tex[to.first] && uxx[to.first][pereb[i]] == 0)||(tex[pereb[i]] < tex[to.first] && uxx[pereb[i]][to.first] == 0))
{
gum++;
pox |= (1LL << to.second);
}
}
}
if (ka.find(pox) == ka.end())
{
ans = (ans + gum / 2) % mod;
ka.insert(pox);
}
} while (next_permutation(pereb.begin(), pereb.end()));
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |