Submission #1052933

# Submission time Handle Problem Language Result Execution time Memory
1052933 2024-08-11T06:17:39 Z vjudge1 Trains (BOI24_trains) C++17
0 / 100
12 ms 34652 KB
                                    ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 100001
const ll M=1e9+7;
vector<int> a[N];
map<int,int> x[N];
map<int,int> y[N];
map<int,int> dp[N];
void solve(){
    int n,m,o;
    ll p,q;
    cin>>n;
    m=0;
    for(int i=1;i<=n;i++){
        o=(i==1);
        cin>>p>>q;
        for(auto& j:a[i])
            o=(o+dp[j][i%j])%M;
        m=(m+o)%M;
        if(p && q){
            y[p][i%p]=max(i,y[p][i%p]); 
            for(int j=y[p][i%p]+p;j<=min(1ll*n,i+p*q);j+=p)
                a[j].append(p);
            y[p][i%p]=min(1ll*n+1,i+p*q);
            dp[p][i%p]=(dp[p][i%p]+o)%M;
            x[i+p*q][p]=(x[i+p*q][p]+o)%M;
        }
        for(auto& j:x[i])
            dp[j.ff][i%j.ff]=(dp[j.ff][i%j.ff]+M-j.ss)%M;
    }
    cout<<m;
}
int terminator(){
    L0TA;
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Incorrect 2 ms 16732 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Incorrect 2 ms 16732 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 16732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 34652 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 2 ms 16732 KB Output is correct
5 Incorrect 2 ms 16732 KB Output isn't correct
6 Halted 0 ms 0 KB -