https://csacademy.com/app/graph_editor/
It says: Internal Server Error
What would you recommend to use instead of CSAcademy's Graph Editor? Thanks in advance
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | awoo | 161 |
2 | maomao90 | 160 |
3 | nor | 157 |
4 | atcoder_official | 156 |
4 | cry | 156 |
6 | -is-this-fft- | 155 |
7 | maroonrk | 154 |
8 | adamant | 153 |
9 | Um_nik | 151 |
10 | djm03178 | 146 |
https://csacademy.com/app/graph_editor/
It says: Internal Server Error
What would you recommend to use instead of CSAcademy's Graph Editor? Thanks in advance
Why can't authors work a little harder and write solutions that are looking good?
For example, this code could be a lot more understanable:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef pair<int,int> pp;
int n,m,ti,top,a[N],d[N],p[N],bz[N],bo[N];
long long ans[1000005];
vector<pp>q[1000005];
vector<int>w[N];
struct dd
{
long long x,y,tg,len;
}tr[N*4];
void make(int x,int l,int r)
{
tr[x].len=r-l+1;
if (l==r) return;
int mid=l+r>>1;
make(x<<1,l,mid),make(x<<1|1,mid+1,r);
}
void down(int x)
{
if (tr[x].x==tr[x].len)
{
tr[x<<1].x=tr[x<<1].len;
tr[x<<1|1].x=tr[x<<1|1].len;
}
if (tr[x].x==0)
{
tr[x<<1].x=0;
tr[x<<1|1].x=0;
}
tr[x<<1].tg+=tr[x].tg;
tr[x<<1].y+=tr[x].tg*tr[x<<1].len;
tr[x<<1|1].tg+=tr[x].tg;
tr[x<<1|1].y+=tr[x].tg*tr[x<<1|1].len;
tr[x].tg=0;
}
void up(int x)
{
tr[x].x=tr[x<<1].x+tr[x<<1|1].x;
tr[x].y=tr[x<<1].y+tr[x<<1|1].y;
}
void clear(int x,int l,int r,int ll,int rr)
{
if (l>=ll && r<=rr)
{
tr[x].tg+=ti;
tr[x].y+=ti*tr[x].len;
tr[x].x=0;
return;
}
down(x);
int mid=l+r>>1;
if (ll<=mid) clear(x<<1,l,mid,ll,rr);
if (rr>mid) clear(x<<1|1,mid+1,r,ll,rr);
up(x);
}
void add(int x,int l,int r,int ll,int rr)
{
if (l>=ll && r<=rr)
{
tr[x].tg-=ti;
tr[x].x=tr[x].len;
tr[x].y-=ti*tr[x].len;
return;
}
down(x);
int mid=l+r>>1;
if (ll<=mid) add(x<<1,l,mid,ll,rr);
if (rr>mid) add(x<<1|1,mid+1,r,ll,rr);
up(x);
}
long long find(int x,int l,int r,int ll,int rr)
{
if (l>=ll && r<=rr) return tr[x].y+ti*tr[x].x;
down(x);
int mid=l+r>>1;
long long ans=0;
if (ll<=mid) ans+=find(x<<1,l,mid,ll,rr);
if (rr>mid) ans+=find(x<<1|1,mid+1,r,ll,rr);
return ans;
}
int main()
{
//freopen("a.in","r",stdin);
//freopen("1.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++) scanf("%d",&a[i]),bz[a[i]]=i;
for (int i=1;i<=m;i++)
{
int l,r;
scanf("%d%d",&l,&r);
q[r].emplace_back(l,i);
}
for (int i=1;i<=n;i++)
for (int j=i;j<=n;j+=i)
w[j].emplace_back(i);
make(1,1,n);
for (int i=1;i<=n;i++)
{
while (top && a[d[top]]<a[i])
{
if (p[top]>d[top-1]) clear(1,1,n,d[top-1]+1,p[top]);
bo[d[top]]=0;
top--;
}
for (int j=a[i];j<=n;j+=a[i])
if (bo[bz[j]])
{
int pt=bo[bz[j]];
int l=d[pt-1]+1,r=d[pt];
int e=bz[j/a[i]];
if (e<l || e>=i) continue;
e=min(e,r);
if (e<=p[pt]) continue;
// if (l<=p[pt]) clear(1,1,n,l,p[pt]);
add(1,1,n,p[pt]+1,e);
p[pt]=e;
}
d[++top]=i;
bo[i]=top;
p[top]=d[top-1];
for (auto j:w[a[i]])
{
int l=d[top-1]+1,r=i;
int e1=bz[j],e2=bz[a[i]/j];
if (e2<=e1) continue;
if (e1<l || e2>i) continue;
if (e1<=p[top]) continue;
// if (l<=p[top]) clear(1,1,n,l,p[top]);
add(1,1,n,p[top]+1,e1);
p[top]=e1;
}
ti++;
for (auto t:q[i]) ans[t.second]=find(1,1,n,t.first,i);
}
for (int i=1;i<=m;i++) printf("%lld\n",ans[i]);
return 0;
}
Name |
---|