Submission #225254

#TimeUsernameProblemLanguageResultExecution timeMemory
225254urd05Wombats (IOI13_wombats)C++14
76 / 100
20086 ms38652 KiB
#include <bits/stdc++.h> #include "wombats.h" using namespace std; struct Node { int arr[200][200]; }; int r,c; const int bs=70; Node merge(Node l,Node r) { int opt[200][200]; Node ret; for(int diff=-c+1;diff<=c-1;diff++) { for(int i=max(-diff,0);i<min(c-diff,c);i++) { int j=i+diff; int st; if (j==0) { st=0; } else { st=opt[i][j-1]; } int en; if (i==c-1) { en=c-1; } else { en=opt[i+1][j]; } int mini=2e9; for(int k=st;k<=en;k++) { if (l.arr[i][k]+r.arr[k][j]<mini) { opt[i][j]=k; mini=l.arr[i][k]+r.arr[k][j]; } } ret.arr[i][j]=mini; } } return ret; } Node tp; Node arr[72]; int h[5000][199]; int v[4999][200]; void update(int node,int nodel,int noder) { for(int st=0;st<c;st++) { int dist[200]; dist[st]=0; for(int i=st-1;i>=0;i--) { dist[i]=dist[i+1]+h[nodel][i]; } for(int i=st+1;i<c;i++) { dist[i]=dist[i-1]+h[nodel][i-1]; } for(int i=nodel+1;i<=noder;i++) { for(int j=0;j<c;j++) { dist[j]=dist[j]+v[i-1][j]; } for(int j=1;j<c;j++) { dist[j]=min(dist[j],dist[j-1]+h[i][j-1]); } for(int j=c-2;j>=0;j--) { dist[j]=min(dist[j],dist[j+1]+h[i][j]); } } for(int i=0;i<c;i++) { arr[node].arr[st][i]=dist[i]; } } } void init(int rr,int cc,int hh[][200],int vv[][200]) { r=rr; c=cc; for(int i=0;i<r;i++) { for(int j=0;j<c-1;j++) { h[i][j]=hh[i][j]; } } for(int i=0;i<r-1;i++) { for(int j=0;j<c;j++) { v[i][j]=vv[i][j]; } } for(int i=0;i<=(r-1)/bs;i++) { update(i,i*bs,min(i*bs+bs,r-1)); } tp=arr[0]; for(int i=1;i<=(r-1)/bs;i++) { tp=merge(tp,arr[i]); } } void changeH(int p,int q,int w) { h[p][q]=w; if (p%bs==0&&p!=0) { update(p/bs-1,(p/bs-1)*bs,(p/bs-1)*bs+bs); update(p/bs,p,min(p+bs,r-1)); } else { update(p/bs,(p/bs)*bs,min((p/bs)*bs+bs,r-1)); } tp=arr[0]; for(int j=1;j<=(r-1)/bs;j++) { tp=merge(tp,arr[j]); } } void changeV(int p,int q,int w) { v[p][q]=w; update(p/bs,(p/bs)*bs,min((p/bs)*bs+bs,r-1)); tp=arr[0]; for(int j=1;j<=(r-1)/bs;j++) { tp=merge(tp,arr[j]); } } int escape(int v1,int v2) { return tp.arr[v1][v2]; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...