QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478490 | #8487. Scooter numbers | rania__# | WA | 406ms | 21972kb | C++23 | 2.1kb | 2024-07-15 01:53:20 | 2024-07-15 01:53:21 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define pp push
#define ceill(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?0:1))
#define floorr(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?-1:0))
#define YN(x) cout<<(x?"YES\n":"NO\n");
#define Yn(x) cout<<(x?"Yes\n":"No\n");
#define yn(x) cout<<(x?"yes\n":"no\n");
const int MAAX=1e18;
const int MOD=1e9+7;
const int MAX=1e9;
template <typename T>
struct segment_tree {
int N;
T E;
vector <T> S;
function <T(T, T)> F;
segment_tree(int n, T e, function <T(T, T)> f) : N(n), E(e), S(n << 1, e), F(f) {}
void update(int j, T x) {
for (S[j += N] = x; j >>= 1; ) S[j] = F(S[j << 1], S[j << 1 | 1]);
}
T get(int L, int R) {
if(L < 0 || R < 0 || L > R) return E;
R++;
T l = E, r = E;
for (L += N, R += N; L < R; L >>= 1, R >>= 1) {
if (L & 1) l = F(l, S[L++]);
if (R & 1) r = F(S[--R], r);
}
return F(l, r);
}
};
segment_tree<int> tree(1000000,0,[](int x,int y){return x+y;});
int n,dp[1010][1010];
in main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tc=1;
// cin>>tc;
while(tc--){
cin>>n;
int ans=0;
for(int t=1;t<=46;t++){
for(int last=0;last<=n;last++){
dp[last][0]=(last+1>=t&&last!=0);
tree.update((0+last)*1000+last,dp[last][0]);
}
for(int last=n;last>=0;last--){
for(int rem=1;rem<=n;rem++){
dp[last][rem]=0;
if(last>=t-1){
dp[last][rem]+=tree.get(rem*1000+max(last,1ll),rem*1000+rem);
if(t>=last&&t<=rem)
dp[last][rem]-=tree.get(rem*1000+t,rem*1000+t);
}
else{
for(int i=last;i<=min(rem,last+1);i++){
if(i==0)
continue;
dp[last][rem]+=dp[i][rem-i];
}
}
dp[last][rem]%=MOD;
if(rem>=last)
tree.update((rem+last)*1000+last,dp[last][rem]);
}
}
ans+=dp[0][n]*t;
}
cout<<ans<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 18652kb
input:
1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 18556kb
input:
3
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 18692kb
input:
2
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 18620kb
input:
5
output:
14
result:
ok 1 number(s): "14"
Test #5:
score: 0
Accepted
time: 3ms
memory: 18748kb
input:
7
output:
32
result:
ok 1 number(s): "32"
Test #6:
score: 0
Accepted
time: 0ms
memory: 18504kb
input:
10
output:
93
result:
ok 1 number(s): "93"
Test #7:
score: 0
Accepted
time: 0ms
memory: 18572kb
input:
15
output:
426
result:
ok 1 number(s): "426"
Test #8:
score: -100
Wrong Answer
time: 406ms
memory: 21972kb
input:
431
output:
145939570381
result:
wrong answer 1st numbers differ - expected: '939569366', found: '145939570381'