Submission #940506

# Submission time Handle Problem Language Result Execution time Memory
940506 2024-03-07T10:05:32 Z shenfe1 Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 262144 KB
#include <bits/stdc++.h>

#pragma optimize("Ofast")
#pragma target("avx2")

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert
// #define int ll

const int MAX=101;
const ll inf=1e9;  
const int mod=1e9+7;
const int mod1=1e9+9;
const ld eps=1e-9;

int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

int binpow(int a,int n){
  if(!n)return 1;
  if(n%2==1)return a*binpow(a,n-1);
  int k=binpow(a,n/2);
  return k*k;
}

#include "wombats.h"

int h[5001][MAX];
int v[5001][MAX];
int n,m;
int d[MAX][5001][MAX];

void calc(int st){
  d[st][n-1][st]=0;
  for(int j=st+1;j<m;j++){
    d[st][n-1][j]=d[st][n-1][j-1]+h[n-1][j-1];
  }
  for(int j=st-1;j>=0;j--){
    d[st][n-1][j]=d[st][n-1][j+1]+h[n-1][j];
  }
  for(int i=n-2;i>=0;i--){
    int pmn[210];
    int smn[210];
    pmn[0]=d[st][i+1][0]+v[i][0];
    for(int j=1;j<m;j++){
      pmn[j]=min(pmn[j-1]+h[i][j-1],d[st][i+1][j]+v[i][j]);
    }
    smn[m-1]=d[st][i+1][m-1]+v[i][m-1];
    for(int j=m-2;j>=0;j--){
      smn[j]=min(smn[j+1]+h[i][j],d[st][i+1][j]+v[i][j]);
    }
    for(int j=0;j<m;j++){
      d[st][i][j]=min(smn[j],pmn[j]);
    }
  }
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
  n=R;
  m=C;
  for(int i=0;i<R;i++){
    for(int j=0;j<C-1;j++){
      h[i][j]=H[i][j];
    }
  }
  for(int i=0;i<R-1;i++){
    for(int j=0;j<C;j++){
      v[i][j]=V[i][j];
    }
  }
  for(int i=0;i<m;i++)calc(i);
}

void changeH(int P, int Q, int W) {
  h[P][Q]=W;
  for(int i=0;i<m;i++){
    calc(i);
  }
}

void changeV(int P, int Q, int W) {
  v[P][Q]=W;
  for(int i=0;i<m;i++){
    calc(i);
  }
}

int escape(int V1, int V2) {
  return d[V2][0][V1];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize("Ofast")
      | 
wombats.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    4 | #pragma target("avx2")
      |
# Verdict Execution time Memory Grader output
1 Correct 17 ms 10840 KB Output is correct
2 Correct 17 ms 10844 KB Output is correct
3 Correct 70 ms 13408 KB Output is correct
4 Correct 17 ms 10844 KB Output is correct
5 Correct 17 ms 10844 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 9 ms 45400 KB Output is correct
5 Correct 5 ms 45404 KB Output is correct
6 Correct 7 ms 45656 KB Output is correct
7 Correct 5 ms 45404 KB Output is correct
8 Correct 5 ms 43356 KB Output is correct
9 Correct 6 ms 45404 KB Output is correct
10 Correct 5 ms 43464 KB Output is correct
11 Correct 58 ms 46416 KB Output is correct
12 Correct 6 ms 45400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 578 ms 185632 KB Output is correct
2 Correct 545 ms 185380 KB Output is correct
3 Correct 562 ms 185636 KB Output is correct
4 Correct 565 ms 185424 KB Output is correct
5 Correct 551 ms 185592 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2693 ms 187640 KB Output is correct
10 Correct 2 ms 12632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 16924 KB Output is correct
2 Correct 46 ms 16988 KB Output is correct
3 Correct 45 ms 16984 KB Output is correct
4 Correct 72 ms 18224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 183636 KB Output is correct
2 Correct 555 ms 185428 KB Output is correct
3 Correct 563 ms 183632 KB Output is correct
4 Correct 566 ms 185644 KB Output is correct
5 Correct 574 ms 183588 KB Output is correct
6 Correct 47 ms 16732 KB Output is correct
7 Correct 47 ms 16984 KB Output is correct
8 Correct 45 ms 16988 KB Output is correct
9 Correct 78 ms 18320 KB Output is correct
10 Correct 17 ms 10844 KB Output is correct
11 Correct 17 ms 10912 KB Output is correct
12 Correct 82 ms 13392 KB Output is correct
13 Correct 17 ms 10840 KB Output is correct
14 Correct 17 ms 10840 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 5 ms 45584 KB Output is correct
19 Correct 6 ms 45404 KB Output is correct
20 Correct 6 ms 45400 KB Output is correct
21 Correct 5 ms 45592 KB Output is correct
22 Correct 5 ms 43512 KB Output is correct
23 Correct 5 ms 45404 KB Output is correct
24 Correct 5 ms 43356 KB Output is correct
25 Correct 60 ms 47628 KB Output is correct
26 Correct 5 ms 45400 KB Output is correct
27 Correct 2696 ms 187724 KB Output is correct
28 Execution timed out 20079 ms 214032 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 552 ms 185732 KB Output is correct
2 Correct 546 ms 185588 KB Output is correct
3 Correct 558 ms 187640 KB Output is correct
4 Correct 554 ms 185428 KB Output is correct
5 Correct 549 ms 183588 KB Output is correct
6 Correct 46 ms 16732 KB Output is correct
7 Correct 46 ms 16988 KB Output is correct
8 Correct 46 ms 16984 KB Output is correct
9 Correct 79 ms 18208 KB Output is correct
10 Correct 17 ms 10844 KB Output is correct
11 Correct 17 ms 10844 KB Output is correct
12 Correct 76 ms 13300 KB Output is correct
13 Correct 17 ms 10844 KB Output is correct
14 Correct 17 ms 10844 KB Output is correct
15 Runtime error 2891 ms 262144 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -