QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#867644 | #2934. How Many Unicycles in a Broken Wheel | WeaRD276# | AC ✓ | 15ms | 3840kb | C++20 | 2.8kb | 2025-01-23 20:55:38 | 2025-01-23 20:55:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
const int N = 4047;
const int MOD = 100007;
ll dp[N][2];
ll add(ll a, ll b)
{
return a + b >= MOD ? a + b - MOD : a + b;
}
ll mult(ll a, ll b)
{
return a * b % MOD;
}
struct DSU
{
vector<int> par;
int n;
int comps;
DSU (int _n, const vector<pii>& ed)
{
n = _n;
par.resize(n);
iota(all(par), 0);
comps = n;
for (const auto& [a, b]: ed)
{
union_sets(a, b);
}
//if (comps == 1)
//{
//for (const auto& [a, b]: ed)
//{
//cerr << a + 1 << ' ' << b + 1 << '\n';
//}
//cerr << "=========================\n";
//}
}
int find_set(int v)
{
if (v == par[v])
return v;
return par[v] = find_set(par[v]);
}
void union_sets(int a, int b)
{
a = find_set(a);
b = find_set(b);
if (a != b)
{
par[b] = a;
comps--;
}
}
};
int solve()
{
int n;
if (!(cin >> n))
return 1;
for (auto& i: dp)
for (auto& ii: i)
ii = 0;
--n;
//vector<pii> ed;
//FOR (i, 1, n)
//{
//ed.pb({i - 1, i});
//}
//FOR (i, 0, n)
//{
//ed.pb({i, n});
//}
//int m = sz(ed);
//assert(m == 2 * n - 1);
//int ans = 0;
//int cnt = 0;
//FOR (mask, 1, 1 << m)
//{
//int p = popcount((unsigned int)mask);
//if (p != n + 1)
//continue;
//cnt++;
//vector<pii> ce;
//FOR (i, 0, m)
//{
//if (mask & 1 << i)
//{
//ce.pb(ed[i]);
//}
//}
//DSU ds(n + 1, ce);
//ans += ds.comps == 1;
//}
//cerr << cnt << '\n';
//cout << ans << "\n";
dp[0][1] = 1;
FOR (i, 1, n + 2)
{
dp[i][0] = add(dp[i - 1][0], dp[i - 1][1]);
dp[i][1] = add(dp[i][0], dp[i - 1][1]);
}
ll ans = 0;
FOR (i, 0, n)
{
FOR (j, i + 1, n)
{
ans = add(ans, mult(dp[i][1], dp[n - j - 1][1]));
}
}
cout << ans << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cerr << "_____________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
5
output:
19
result:
ok single line: '19'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3840kb
input:
1234
output:
50380
result:
ok single line: '50380'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 15ms
memory: 3840kb
input:
4000
output:
14774
result:
ok single line: '14774'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
10
output:
5911
result:
ok single line: '5911'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
6
output:
65
result:
ok single line: '65'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
7
output:
210
result:
ok single line: '210'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
8
output:
654
result:
ok single line: '654'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
9
output:
1985
result:
ok single line: '1985'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
779
output:
59262
result:
ok single line: '59262'
Test #11:
score: 0
Accepted
time: 4ms
memory: 3712kb
input:
2320
output:
14502
result:
ok single line: '14502'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
768
output:
57480
result:
ok single line: '57480'
Test #13:
score: 0
Accepted
time: 6ms
memory: 3712kb
input:
2471
output:
10444
result:
ok single line: '10444'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
796
output:
24011
result:
ok single line: '24011'
Test #15:
score: 0
Accepted
time: 14ms
memory: 3840kb
input:
3931
output:
57605
result:
ok single line: '57605'
Test #16:
score: 0
Accepted
time: 4ms
memory: 3712kb
input:
2508
output:
32594
result:
ok single line: '32594'
Test #17:
score: 0
Accepted
time: 9ms
memory: 3712kb
input:
3093
output:
48868
result:
ok single line: '48868'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
138
output:
64281
result:
ok single line: '64281'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
1367
output:
23969
result:
ok single line: '23969'
Test #20:
score: 0
Accepted
time: 5ms
memory: 3712kb
input:
2335
output:
82476
result:
ok single line: '82476'