Submission #1052929

# Submission time Handle Problem Language Result Execution time Memory
1052929 2024-08-11T06:10:53 Z vjudge1 Trains (BOI24_trains) C++17
0 / 100
12 ms 34648 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 m,o;
    ll n,p,q;
    cin>>n;
    m=0;
    for(ll i=1;i<=n;i++){
        cin>>p>>q;
        o=0;
        if(i==1) o=1;
        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,1ll*y[p][i%p]); 
            for(int j=y[p][i%p]+p;j<=min(n,i+p*q);j+=p)
                a[j].append(p);
            y[p][i%p]=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 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Incorrect 3 ms 16732 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Incorrect 3 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 34648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 2 ms 16732 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Incorrect 3 ms 16732 KB Output isn't correct
6 Halted 0 ms 0 KB -