省略
省略
C++に変換後のコードはこちら
int D, L, N, C[2d5], K, F, T;
int ind[2d5];
int *sz, **arr, **tot;
int solve(int sz ,int *arr, int *tot, int F, int T){
int i, j, res = 0;
if(sz==0) return 0;
i = lower_bound(arr, arr+sz, F) - arr;
if(arr[i] != F){
T -= 1 + (arr[i] - F - 1) / L;
if(T < 0) return res;
}
if(i==sz) i = 0;
if(tot[i] < T){
res += sz - i;
T -= tot[i];
i = 0;
res += (T / tot[0]) * sz;
T %= tot[0];
}
j = bsearch_max[int,x,0,sz](T >= tot[i]-tot[x]);
res += j - i + 1;
return res;
}
{
int res;
rd(D,L,N,(C--)(D));
rep(i,D) ind[i] = i;
rep(i,1d5) C[D+i] = i;
wAdjEdge(1d5, D+1d5, C, ind, ind, &sz, &arr, &tot);
rep(i,1d5) sz[i]--;
rep(i,1d5) if(sz[i]){
arr[i][sz[i]] = arr[i][0] + D;
rrep(j,sz[i]) tot[i][j] = tot[i][j+1] + 1 + (arr[i][j+1] - arr[i][j] - 1) / L;
}
rep(N){
rd(K--, F--, T--);
res = solve(sz[K], arr[K], tot[K], F, T);
wt(res);
}
}
Current time: 2024年04月26日02時13分14秒
Last modified: 2021年01月02日17時04分54秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder
トップページに戻る
Logged in as: unknown user (not login)