# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
126101 |
2019-07-07T03:47:52 Z |
nxteru |
Wombats (IOI13_wombats) |
C++14 |
|
905 ms |
262148 KB |
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000001
#define B 5
struct node{
int n,d[200][200];
void ini(int x){
n=x;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)d[i][j]=0;
else d[i][j]=INF;
}
}
}
node plus(node &q){
node res;
res.ini(n);
int a[205][205];
for(int i=n-1;i>-n;i--){
for(int j=max(-i,0);i+j<n&&j<n;j++){
int x,y;
if(j-1>=0)x=a[i+j][j-1];
else x=0;
if(i+j+1<n)y=a[i+j+1][j];
else y=n-1;
for(int k=x;k<=y;k++)if(d[i+j][k]+q.d[k][j]<d[i+j][x]+q.d[x][j])x=k;
a[i+j][j]=x;
res.d[i+j][j]=min(d[i+j][x]+q.d[x][j],INF);
}
}
return res;
}
};
struct SEG{
int n,k,id[1<<11];
node seg[2003];
void ini(int x){
n=x;
for(int i=0;i<1<<11;i++)id[i]=-1;
k=0;
for(int i=0;i<1000;i++){
int a=i+(1<<10)-1;
if(id[a]==-1)id[a]=k++;
while(a>0){
a=(a-1)/2;
if(id[a]==-1)id[a]=k++;
if(id[a*2+1]==-1)id[a*2+1]=k++;
if(id[a*2+2]==-1)id[a*2+2]=k++;
}
}
for(int i=0;i<k;i++)seg[i].ini(n);
}
void up(int a,node &q){
a+=(1<<10)-1;
seg[id[a]]=q;
while(a>0){
a=(a-1)/2;
seg[id[a]]=seg[id[a*2+1]].plus(seg[id[a*2+2]]);
}
}
int dis(int a,int b){
return seg[id[0]].d[a][b];
}
};
int h[5005][205],w[5005][205],n,m,p[B][205];
SEG s;
node res[B];
void change(int x){
x=x/B;
for(int i=0;i<B&&x*B+i<n;i++)p[i][0]=0,res[i].ini(m);
for(int i=0;i<B&&x*B+i<n;i++)for(int j=1;j<m;j++)p[i][j]=p[i][j-1]+h[x*B+i][j-1];
for(int i=0;i<B&&x*B+i<n;i++){
for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
res[i].d[j][k]=p[i][max(j,k)]-p[i][min(j,k)]+w[x*B+i][k];
}
}
}
for(int i=1;i<B&&x*B+i<n;i++)res[0]=res[0].plus(res[i]);
s.up(x,res[0]);
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n=R,m=C;
s.ini(m);
for(int i=0;i<n;i++)for(int j=0;j<m-1;j++)h[i][j]=H[i][j];
for(int i=0;i<n-1;i++)for(int j=0;j<m;j++)w[i][j]=V[i][j];
for(int i=0;i<n;i++)change(i);
}
void changeH(int a, int b, int x) {
h[a][b]=x;
change(a);
}
void changeV(int a, int b, int x) {
w[a][b]=x;
change(a);
}
int escape(int a, int b) {
return s.seg[0].d[a][b];
}
Compilation message
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 time |
Memory |
Grader output |
1 |
Runtime error |
905 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
10748 KB |
Output is correct |
2 |
Correct |
10 ms |
10744 KB |
Output is correct |
3 |
Correct |
10 ms |
10876 KB |
Output is correct |
4 |
Incorrect |
40 ms |
41336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
679 ms |
169248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
885 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
665 ms |
169088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
665 ms |
169148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |