Submission #1000571

# Submission time Handle Problem Language Result Execution time Memory
1000571 2024-06-17T19:55:30 Z arashMLG Trains (BOI24_trains) C++17
0 / 100
65 ms 4736 KB
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...)    69
#define debugArr(...)  69
#endif
using namespace std;

typedef long long     ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;

const int N = 1e5 + 23;
const int sq = 320;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define F           first
#define S           second
#define pb          push_back
#define kill(x)     cout<<x<<endl, exit(0);
#define all(x)      x.begin(),x.end()
#define sz(x)       (int)x.size()
#define lc          (v << 1)
#define rc          ((v<<1) |1)
#define int         ll

void ok(int &x) {
	if(x < 0) x += mod*mod;
	x %= mod;
}

int n;
int d[N],x[N];
int dp[N];
vector<int> vals[N];
int sum[sq][sq];

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n;
	for(int i = 1; i <= n ; i ++) cin>>d[i]>>x[i];
	dp[1] = 1;
	int ans = 0;
	for(int i = 1; i <= n; i ++) {
		for(int j = 1 ; j < sq; j ++) {
			ok(dp[i] += sum[j][i%j]);
		}
		if(d[i] != 0) {
			if(d[i] < sq) {
				if(i + d[i]*x[i] <= n) {
					vals[i + d[i]*x[i]].pb(i);
					ok(sum[d[i]][i%d[i]] += dp[i]);
				}
			} else {
				for(int j = i+d[i]; j <= n && x[i]--;j += d[i]) {
					ok(dp[j] += dp[i]);
				}
			}
		}
		for(int j : vals[i]) ok(sum[d[j]][j%d[j]] -= dp[j]);
		ok(ans += dp[i]);
		debug(i,dp[i]);
	}
	cout<<ans << '\n';
	return 0;
}

// Jumpsuit, Jumpsuit cover me!
// Jumpsuit, Jumpsuit cover me!

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:5:23: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...)    69
      |                       ^~
Main.cpp:64:3: note: in expansion of macro 'debug'
   64 |   debug(i,dp[i]);
      |   ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 4736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -