RT,第二个样例都过不了
如果有大佬可以给出规模较小的hack数据也行
#include <bits/stdc++.h>
#define int1 unsigned long long
#define N 200000
#define M 1000000
#define INF 18446744073709551615ull
#define P pair<int1,int1>
using namespace std;
int1 n,h,i,y,z,ans,dis[N + 5];
bool b[N + 5];
int1 hea[N + 5],nex[M + 5],to[M + 5],w[M + 5],bs/*,ru[M + 5],chu[M + 5]*/;
int1 read(){
int1 x = 0,f = 1;
char ch = getchar();
while(!isdigit(ch)){
if(ch == '-'){
f = -1;
}
ch = getchar();
}
while(isdigit(ch)){
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
void uprint(int1 x){
if(x > 9){
uprint(x / 10);
}
putchar(x % 10 ^ 48);
return ;
}
void print(int1 x){
if(x < 0){
putchar('-');
x = -x;
}
uprint(x);
return ;
}
void ps(int1 x){
print(x);
putchar(' ');
return ;
}
void pe(int1 x){
print(x);
putchar('\n');
return ;
}
void add_edge(int1 x,int1 y,int1 z){
nex[++bs] = hea[x],hea[x] = bs,to[bs] = y,w[bs] = z/*,ru[y]++,chu[x]++*/;
return ;
}
void two_edge(int1 x,int1 y,int1 z){
add_edge(x,y,z),add_edge(y,x,z);
return ;
}
void dijkstra(int1 st){
// for(int1 i = 1; i <= n; i++){
// dis[i] = INF,b[i] = 0;
// }
for(int1 i = 0; i < n; i++){
dis[i] = INF,b[i] = 0;
}
dis[st] = 0;
priority_queue<P,vector<P >,greater<P > > q;
q.push(make_pair(0,st));
while(!q.empty()){
int1 x = q.top().second;
q.pop();
if(b[x]){
continue;
}
b[x] = 1;
for(int1 i = hea[x]; i; i = nex[i]){
int1 y = to[i],d = dis[x] + w[i];
if(d < dis[y]){
dis[y] = d;
q.push(make_pair(d,y));
}
}
}
return ;
}
int main(){
h = read() - 1,n = read(),y = read(),z = read();
for(i = 0; i < n; i++){
two_edge(i,(i + y) % n,y);
two_edge(i,(i + z) % n,z);
}
dijkstra(0);
for(i = 0; i < n; i++){
if(dis[i] <= h){
ans += (h - dis[i]) / n + 1;
}
}
pe(ans);
return 0;
}