Submission #73138596
Source Code Expand
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <random>
#include <atcoder/dsu>
#include <atcoder/modint>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#include <atcoder/fenwicktree>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i,n) for (ll i = n-1; i >= 0; i--)
#define rep1(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep3(i, s, t) for(ll i = s; i < (ll)(t); i++)
//#define ll int64_t
#define ll long long
#define pb push_back
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define p3(s, t, u) cout << (s) << " " << (t) << " " << (u) << '\n'
#define p4(s, t, u, v) cout << (s) << " " << (t) << " " << (u) << " " << (v) << '\n'
template<class T>
inline int sz(const T& x) { return (int)x.size(); }
#define Sort(A) sort(all(A))
#define RSort(A) sort(rall(A))
#define p_yes() p("Yes")
#define p_no() p("No")
#define pe(s) cout <<(s)<<' ';
#define pval(s) cout << (s).val() << '\n'
using inverse_priority_queue = priority_queue<ll, vector<ll>, greater<ll>>;//小さい順のpriority_queue
const ll Inf = 2147483647;
const ll Inf9 = 1000000000;
const ll inf = 9223372036854775807;
const ll inf18 = 1000000000000000000;
using LL = __int128;
using mint = modint998244353;
const ll mod = 998244353;
//const ll mod = 1000000007;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tu;
using vl = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using vs = vector<string>;
using vc = vector<char>;
using vmi = vector<mint>;
ll gcd(ll a, ll b){if(a%b == 0)return b;else return gcd(b, a%b);}//最大公約数
ll lcm(ll a, ll b){return a*b / gcd(a, b);}//最小公倍数
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void Uni_erase(std::vector<T>& vec) {
std::sort(vec.begin(), vec.end());
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());}
map<pair<ll,ll>,ll> Pow_map;
ll Pow(ll x, ll y) {if (Pow_map.count({x, y})) return Pow_map[{x, y}];
ll res = 1, base = x;while (y > 0) {if (y & 1) res *= base;base *= base;y >>= 1;}return Pow_map[{x, y}] = res;}
ll Exp(ll x, ll y){ll cnt = -1;while(x>0){x/=y;cnt++;}return cnt;}
ll powmod(ll x, ll k, int mod){if (k == 0) return 1%mod;ll res = powmod(x,k/2,mod);res = (res*res)%mod;if (k%2 == 1) res = (res*x)%mod;return res;}
inline bool OutIn(ll x, ll y, ll height, ll width) {return 0 <= x && x < height && 0 <= y && y < width;}
std::mt19937 rng(std::random_device{}());
ll Random(ll l, ll r) {std::uniform_int_distribution<long long> dist(l, r - 1);return dist(rng);}
vl cin_vl(ll n){vl ret(n); rep(i,n) cin >> ret[i]; return ret;}
pair<vl,vl> cin_xy(ll n){vl x(n), y(n); rep(i,n) cin >> x[i] >> y[i]; return {x,y};}
vvl Cin_vl(ll n, ll k){vvl ret(k,vl(n));rep(i,n)rep(j,k) cin >> ret[j][i]; return ret;}
void cout_vl(vl a){for(auto e : a)cout << e << ' '; cout << endl;}
void Cout_vl(vl a, vl b){ll n = sz(a); rep(i,n)cout << a[i] << ' ' << b[i] << endl;}
void cout_vvl(vvl a){for(auto e : a){cout_vl(e);} cout<< endl;}
//cout << fixed << setprecision(10)
using Graph = vector<vector<pair<ll,ll>>>;
using graph = vector<vector<int>>;
//vector<vector<bool>> seen(h,vector<bool>(w,false));
//seen.assign(h, vector<bool>(w, false));
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
const int MAX_N = 50;
long long Com[MAX_N][MAX_N];
void init(ll mod) {
memset(Com, 0, sizeof(Com));
Com[0][0] = 1;
for (int i = 1; i < MAX_N; ++i) {
Com[i][0] = 1;
for (int j = 1; j < MAX_N; j++) {
Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % mod;
}
}
}
//Com[x][y] = (x)C(y)%mod
int main() {
ll n;
cin >> n;
init(inf);
vvl ans(n,vl(n));
rep1(i,n)rep1(j,n){
ll a = 0;
ll m = 2*n - i - j - 1;
if(m < 0) break;
rep1(k,i-1) a += Com[m][n-k-1];
ans[i-1][j-1] = a;
}
cout_vvl(ans);
}
Submission Info
| Submission Time |
|
| Task |
D - Distinct Sum Grid Path |
| User |
yuki4869 |
| Language |
C++23 (GCC 15.2.0) |
| Score |
700 |
| Code Size |
4302 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3784 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
700 / 700 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample-01.txt, sample-02.txt |
| All |
01-03.txt, 01-04.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, sample-01.txt, sample-02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 01-03.txt |
AC |
1 ms |
3596 KiB |
| 01-04.txt |
AC |
1 ms |
3524 KiB |
| 01-06.txt |
AC |
1 ms |
3516 KiB |
| 01-07.txt |
AC |
1 ms |
3604 KiB |
| 01-08.txt |
AC |
1 ms |
3484 KiB |
| 01-09.txt |
AC |
1 ms |
3648 KiB |
| 01-10.txt |
AC |
1 ms |
3572 KiB |
| 01-11.txt |
AC |
1 ms |
3784 KiB |
| 01-12.txt |
AC |
1 ms |
3564 KiB |
| 01-13.txt |
AC |
1 ms |
3484 KiB |
| sample-01.txt |
AC |
1 ms |
3616 KiB |
| sample-02.txt |
AC |
1 ms |
3676 KiB |