Submission #1051506

# Submission time Handle Problem Language Result Execution time Memory
1051506 2024-08-10T07:38:47 Z Malix Trains (BOI24_trains) C++14
34 / 100
217 ms 504472 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
 
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
 
int n;
vector<ll> dp;
vi d,x;
int m;
int dd=1e5;
 
int main() {   
// ios::sync_with_stdio(0);
// cin.tie(0);
    cin>>n;
    d.resize(n);x.resize(n);
    REP(i,0,n)cin>>d[i]>>x[i];
    m=sqrt(n)+1;
    ll ans=0;
    vector<ll> val(n,0);
    val[0]=1;
    vector<vector<ll>> arr(n,vector<ll>(m,0));
    vector<vector<ll>> arr2(n,vector<ll>(m,0));
    REP(i,0,n){
        REP(j,1,m){
            if(arr[i][j]==0)continue;
            val[i]+=arr[i][j];
            val[i]%=M; 
            arr[i][j]-=arr2[i][j];
            arr[i][j]+=M;
            arr[i][j]%=M;
            if(i+j<n)arr[i+j][j]=arr[i][j];
        }
        if(d[i]==0)continue;
        if(d[i]<m){
            if(i+d[i]<n){
                arr[i+d[i]][d[i]]+=val[i];
                arr[i+d[i]][d[i]]%=M;
            }
            ll k=(ll)i+(ll)d[i]*(ll)x[i];
            if((k-i)/d[i]!=x[i]){
                int ddd=0;
                while(ddd==0){
                    ddd=0;
                }
            }
            if(k<(ll)n){
                arr2[i+d[i]*x[i]][d[i]]+=val[i];
                arr2[i+d[i]*x[i]][d[i]]%=M;
            }
        }
        else{
            REP(j,1,x[i]+1){
                if(i+d[i]*j>=n)break;
                val[i+d[i]*j]+=val[i];
                val[i+d[i]*j]%=M;
            }
        }
    }
    REP(i,0,n){
        ans+=val[i];
        ans%=M;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 9052 KB Output is correct
3 Correct 3 ms 5468 KB Output is correct
4 Correct 6 ms 13460 KB Output is correct
5 Correct 131 ms 343772 KB Output is correct
6 Correct 201 ms 504404 KB Output is correct
7 Correct 201 ms 504404 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 84 ms 170580 KB Output is correct
2 Correct 59 ms 129268 KB Output is correct
3 Correct 217 ms 504404 KB Output is correct
4 Correct 126 ms 307540 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 16 ms 16996 KB Output is correct
8 Correct 207 ms 504472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -