| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 645272 | ghostwriter | Skyscraper (JOI16_skyscraper) | C++14 | 139 ms | 58772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define FRN(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define FSN(i, n) for (int (i) = (n) - 1; (i) >= 0; --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
END OF TEMPLATE
----------------------------------------------------------------
Tran The Bao - ghostwriter
Training for VOI23 gold medal
----------------------------------------------------------------
MAI YEU CHUYEN BAO LOC
----------------------------------------------------------------
*/
const int M = 1e9 + 7;
const int N = 102;
const int L = 1e3 + 2;
int n, l, a[N], d[N][N][3][L], rs = 0;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
cin >> n >> l;
FOR(i, 1, n) cin >> a[i];
a[n + 1] = L;
sort(a + 1, a + 1 + n);
if (n == 1) {
cout << 1;
return 0;
}
d[0][0][0][0] = 1;
FOR(i, 1, n)
FOR(j, 1, i)
FOR(z, 0, 2)
FOR(x, 0, l) {
int &rs = d[i][j][z][x];
int newx = x - (2 * j - z) * (a[i + 1] - a[i]);
if (newx < 0) continue;
rs = (rs + d[i - 1][j - 1][z][newx]) % M;
if (z) rs = (rs + 1LL * (3 - z) * d[i - 1][j - 1][z - 1][newx] % M) % M;
rs = (rs + 1LL * (2 * j - z) * d[i - 1][j][z][newx] % M) % M;
if (z) {
if (z == 1) rs = (rs + 2LL * j * d[i - 1][j][z - 1][newx] % M) % M;
else if (j == 1) {
if (i == n) rs = (rs + d[i - 1][j][z - 1][newx]) % M;
}
else rs = (rs + 1LL * (j - 1) * d[i - 1][j][z - 1][newx] % M) % M;
}
if (j) {
if (z == 0) rs = (rs + 1LL * j * (j + 1) % M * d[i - 1][j + 1][z][newx]) % M;
else if (z == 1) rs = (rs + 1LL * j * j % M * d[i - 1][j + 1][z][newx] % M) % M;
else {
if (i == n) rs = (rs + d[i - 1][j + 1][z][newx]) % M;
else rs = (rs + 1LL * j * (j - 1) % M * d[i - 1][j + 1][z][newx] % M) % M;
}
}
}
FOR(i, 0, l) rs = (rs + d[n][1][2][i]) % M;
cout << rs;
return 0;
}
/*
4 10
3 6 2 9
----------------------------------------------------------------
From Benq:
stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/
컴파일 시 표준 에러 (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... | ||||
