제출 #65037

#제출 시각아이디문제언어결과실행 시간메모리
65037gnoor웜뱃 (IOI13_wombats)C++17
55 / 100
6650 ms263168 KiB
#include "wombats.h" #include <vector> #include <cmath> #include <cstdio> using namespace std; typedef vector<vector<int>> tbl; int r,c; int opt[200][200]; tbl combine(const tbl &a, const tbl &b) { tbl tmp(c,vector<int>(c,1e9)); for (int sz=-c+1;sz<c;sz++) { for (int i=0;i<c;i++) { int j=i+sz; if (j<0||j>=c) continue; for (int k=(j==0?0:opt[i][j-1]);k<=(i==c-1?c-1:opt[i+1][j]);k++) { if (a[i][k]+b[k][j]<tmp[i][j]) { tmp[i][j]=a[i][k]+b[k][j]; opt[i][j]=k; } } } } return tmp; } int h[5000][200]; int v[5000][200]; int qsh[5000][200]; //0 <= row < r-1 tbl build(int row) { tbl tmp(c,vector<int>(c,1e9)); int da,db; for (int sz=-c+1;sz<c;sz++) { for (int i=0;i<c;i++) { int j=i+sz; if (j<0||j>=c) continue; for (int k=(j==0?0:opt[i][j-1]);k<=(i==c-1?c-1:opt[i+1][j]);k++) { da=abs((k==0?0:qsh[row][k-1])-(i==0?0:qsh[row][i-1])); db=abs((k==0?0:qsh[row+1][k-1])-(j==0?0:qsh[row+1][j-1])); if (da+db+v[row][k]<tmp[i][j]) { tmp[i][j]=da+db+v[row][k]; opt[i][j]=k; } } } } return tmp; } tbl seg[30100]; void buildseg(int id,int ll,int rr) { if (ll+1==rr) { seg[id]=build(ll); return; } int m=(ll+rr)>>1; buildseg(id*2,ll,m); buildseg(id*2+1,m,rr); seg[id]=combine(seg[id*2],seg[id*2+1]); } void update(int id,int ll,int rr,int k) { if (ll+1==rr) { seg[id]=build(ll); return; } int m=(ll+rr)>>1; if (k<m) update(id*2,ll,m,k); else update(id*2+1,m,rr,k); seg[id]=combine(seg[id*2],seg[id*2+1]); } void init(int R, int C, int H[5000][200], int V[5000][200]) { r=R; c=C; for (int i=0;i<R;i++) { for (int j=0;j<c;j++) { h[i][j]=H[i][j]; v[i][j]=V[i][j]; } } for (int i=0;i<r;i++) { qsh[i][0]=h[i][0]; for (int j=1;j<c-1;j++) { qsh[i][j]=qsh[i][j-1]+h[i][j]; } } buildseg(1,0,r-1); } void changeH(int P, int Q, int W) { h[P][Q]=W; qsh[P][0]=h[P][0]; for (int j=1;j<c-1;j++) { qsh[P][j]=qsh[P][j-1]+h[P][j]; } update(1,0,r-1,P); if (P) update(1,0,r-1,P-1); } void changeV(int P, int Q, int W) { v[P][Q]=W; update(1,0,r-1,P); } int escape(int V1, int V2) { return seg[1][V1][V2]; }

컴파일 시 표준 에러 (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...