이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Copyright © 2022 Youngmin Park. All rights reserved.
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpi = vector<pii>;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
using ld = long double;
template <typename T, size_t SZ>
using ar = array<T, SZ>;
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a)
#define REP(a) F0R(_, a)
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 998244353;
const ld PI = acos((ld)-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v)
{
    os << '{';
    string sep;
    for (const T &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
void dbg_out()
{
    cerr << endl;
}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif
inline namespace RecursiveLambda{
	template <typename Fun>
	struct y_combinator_result{
		Fun fun_;
		template <typename T> 
		explicit y_combinator_result(T &&fun): fun_(forward<T>(fun)){}
		template <typename...Args>
		decltype(auto) operator()(Args &&...args){
			return fun_(ref(*this), forward<Args>(args)...);
		}
	};
	template <typename Fun>
	decltype(auto) y_combinator(Fun &&fun){
		return y_combinator_result<decay_t<Fun>>(forward<Fun>(fun));
	}
};
void setIO(string s) // USACO
{
	#ifndef LOCAL
	    freopen((s + ".in").c_str(), "r", stdin);
	    freopen((s + ".out").c_str(), "w", stdout);
	#endif
}
#define int long long
int dp[1 << 18];
int comp[1 << 18];
int ways[1 << 18];
int cnt[1 << 18][18];
bool g[18][18], good[18][18];
vi adj[18];
int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}
int mul(int a, int b) {
	return 1LL * a * b;
}
int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}
void solve()
{
	int n, m;
	cin >> n >> m;
	REP(m) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[v][u] = 1;
		adj[u].pb(v), adj[v].pb(u);
	}
	F0R(i, n) F0R(j, n) {
		if (g[i][j] == g[j][i]) {
			good[i][j] = good[j][i] = 1;
		}
	}
	comp[0] = 1;
	F0R(mask, 1 << n) {
		F0R(i, n) {
			if (!((1 << i) & mask)) continue;
			int pmask = mask ^ (1 << i);
			if (comp[pmask] == 0) break;
			bool ok = 1;
			F0R(j, n) {
				if ((pmask & (1 << j)) && !good[i][j]) {
					ok = 0;
				}
			}
			comp[mask] = ok;
		}
	}
	F0R(mask, 1 << n) {
		F0R(j, n) {
			if (!((1 << j) & mask)) continue;
			F0R(k, n) {
				if ((1 << k) & mask) {
					cnt[mask - (1 << j)][j] += g[j][k];
				}
			}
		}
	}
	ways[0] = 1;
	FOR(mask, 1, 1 << n) {
		for (int cur = mask; cur; cur = (cur - 1) & mask) {
			if (!comp[cur]) continue;
			int k = __builtin_popcount(cur);
			int val{};
			F0R(j, n) {
				if ((1 << j) & cur) {
					val += cnt[mask - cur][j];
				}
			}
			val = mul(val, ways[mask - cur]);
			val = add(val, dp[mask - cur]);
			dbg(mask, cur, val);
			if (k & 1) dp[mask] = add(dp[mask], val), ways[mask] = add(ways[mask], ways[mask - cur]);
			else dp[mask] = sub(dp[mask], val), ways[mask] = sub(ways[mask], ways[mask - cur]);
		}
		dbg(ways[mask]);
	}
	cout << dp[(1 << n) - 1];
}
int32_t main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    int testcase=1;
    // cin >> testcase;
    while (testcase--)
    {
        solve();
    }
}
컴파일 시 표준 에러 (stderr) 메시지
amusementpark.cpp: In function 'void solve()':
amusementpark.cpp:71:18: warning: statement has no effect [-Wunused-value]
   71 | #define dbg(...) 42
      |                  ^~
amusementpark.cpp:179:4: note: in expansion of macro 'dbg'
  179 |    dbg(mask, cur, val);
      |    ^~~
amusementpark.cpp:71:18: warning: statement has no effect [-Wunused-value]
   71 | #define dbg(...) 42
      |                  ^~
amusementpark.cpp:183:3: note: in expansion of macro 'dbg'
  183 |   dbg(ways[mask]);
      |   ^~~
amusementpark.cpp: In function 'void setIO(std::string)':
amusementpark.cpp:94:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |      freopen((s + ".in").c_str(), "r", stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:95:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |      freopen((s + ".out").c_str(), "w", stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |