Submission #34350536


Source Code Expand

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const ll mod = 998244353;

ll n;

ll poww(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}

ll inv(ll x) {
  return poww(x, mod - 2);
}

ll fact(ll n) {
  ll ans = 1;
  for (ll i = 2; i <= n; i++)
    ans = (ans * i) % mod;
  return ans;
}

ll comb(ll n, ll k) {
  ll up = fact(n);
  ll down = (fact(k) * fact(n - k)) % mod;
  return (up * inv(down)) % mod;
}

int main()
{
  cin >> n;

  ll ans = (n * n) % mod;
  ans = (ans * comb(n * n, 2 * n - 1)) % mod;
  ans = (ans * fact(n - 1)) % mod;
  ans = (ans * fact(n - 1)) % mod;
  ans = (ans * fact(n * n - 2 * n + 1)) % mod;
  ans = (fact(n * n) + mod - ans) % mod;
  cout << ans;



  return 0;
}

Submission Info

Submission Time
Task B - Counting Grids
User atatomir
Language C++ (GCC 9.2.1)
Score 500
Code Size 1000 Byte
Status AC
Exec Time 11 ms
Memory 3640 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 16
Set Name Test Cases
Sample sample01.txt, sample02.txt, sample03.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, sample01.txt, sample02.txt, sample03.txt
Case Name Status Exec Time Memory
in01.txt AC 11 ms 3412 KiB
in02.txt AC 5 ms 3456 KiB
in03.txt AC 7 ms 3572 KiB
in04.txt AC 3 ms 3456 KiB
in05.txt AC 4 ms 3568 KiB
in06.txt AC 4 ms 3392 KiB
in07.txt AC 4 ms 3588 KiB
in08.txt AC 5 ms 3588 KiB
in09.txt AC 3 ms 3568 KiB
in10.txt AC 3 ms 3624 KiB
in11.txt AC 10 ms 3408 KiB
in12.txt AC 7 ms 3640 KiB
in13.txt AC 2 ms 3528 KiB
sample01.txt AC 2 ms 3568 KiB
sample02.txt AC 2 ms 3640 KiB
sample03.txt AC 2 ms 3528 KiB