Submission #404030

# Submission time Handle Problem Language Result Execution time Memory
404030 2021-05-13T17:07:40 Z PedroBigMan Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 262148 KB
#include "wombats.h"
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}

vector<vector<ll> > v,h; ll R,C;
vector<vector<vector<ll> > > d;
vector<ll> up; vector<ll> ps; vector<ll> val1,val2; 

void CalcDist(ll s)
{
	REP(i,0,C) {up[i]=INF;} up[s]=0; 
	ll sum,val;
	REP(r,0,R)
	{
		sum=0LL; ps[0]=0; REP(i,0,C-1) {sum+=h[r][i]; ps[i+1]=sum;}	
		val=INF;
		REP(i,0,C) {val1[i]=val; val=min(val,up[i]-ps[i]);}
		val=INF;
		for(ll i=C-1;i>=0;i--) {val2[i]=val; val=min(val,up[i]+ps[i]);}
		REP(i,0,C) 
		{
			d[s][r][i]=min(up[i],min(val1[i]+ps[i],val2[i]-ps[i])); if(r!=R-1) {up[i]=d[s][r][i]+v[r][i];}
		}			
	}
}

void init(int r, int c, int H[5000][200], int V[5000][200]) 
{
    R=(ll) r; C = (ll) c; vector<ll> xx; REP(i,0,C-1) {xx.pb(0);} REP(i,0,R) {h.pb(xx);} xx.pb(0LL); REP(i,0,R-1) {v.pb(xx);}
	REP(i,0,R) {REP(j,0,C-1) {h[i][j]=H[i][j];}} 
	REP(i,0,R-1) {REP(j,0,C) {v[i][j]=V[i][j];}}
	vector<vector<ll> > grid; REP(i,0,R) {grid.pb(xx);} REP(i,0,C) {d.pb(grid);}
	REP(i,0,C) {up.pb(INF);} REP(i,0,C) {ps.pb(0LL); val1.pb(0LL); val2.pb(0LL);}
	REP(i,0,C) {CalcDist(i);}
	return;
}

void changeH(int p, int q, int W) 
{
    h[p][q]=W; REP(i,0,C) {CalcDist(i);}
}

void changeV(int p, int q, int W) 
{
   	v[p][q]=W; REP(i,0,C) {CalcDist(i);}
}

int escape(int v1, int v2) 
{
   	return d[v1][R-1][v2];
}

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:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
wombats.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5132 KB Output is correct
2 Correct 28 ms 5132 KB Output is correct
3 Correct 104 ms 6640 KB Output is correct
4 Correct 28 ms 5132 KB Output is correct
5 Correct 28 ms 5132 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 86 ms 1320 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 604 ms 4840 KB Output is correct
2 Correct 587 ms 4812 KB Output is correct
3 Correct 603 ms 4812 KB Output is correct
4 Correct 602 ms 4932 KB Output is correct
5 Correct 605 ms 4848 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 2971 ms 4888 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 9420 KB Output is correct
2 Correct 81 ms 9420 KB Output is correct
3 Correct 82 ms 9504 KB Output is correct
4 Correct 124 ms 10068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 596 ms 4844 KB Output is correct
2 Correct 648 ms 4812 KB Output is correct
3 Correct 610 ms 4932 KB Output is correct
4 Correct 666 ms 4932 KB Output is correct
5 Correct 626 ms 4932 KB Output is correct
6 Correct 82 ms 9420 KB Output is correct
7 Correct 95 ms 9420 KB Output is correct
8 Correct 82 ms 9420 KB Output is correct
9 Correct 121 ms 10084 KB Output is correct
10 Correct 28 ms 5132 KB Output is correct
11 Correct 28 ms 5132 KB Output is correct
12 Correct 108 ms 6620 KB Output is correct
13 Correct 28 ms 5132 KB Output is correct
14 Correct 28 ms 5132 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 77 ms 1312 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 3149 ms 4888 KB Output is correct
28 Execution timed out 20105 ms 233464 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 601 ms 4852 KB Output is correct
2 Correct 592 ms 4812 KB Output is correct
3 Correct 592 ms 4812 KB Output is correct
4 Correct 594 ms 4812 KB Output is correct
5 Correct 608 ms 4812 KB Output is correct
6 Correct 82 ms 9420 KB Output is correct
7 Correct 81 ms 9420 KB Output is correct
8 Correct 82 ms 9420 KB Output is correct
9 Correct 122 ms 10192 KB Output is correct
10 Correct 29 ms 5132 KB Output is correct
11 Correct 29 ms 5132 KB Output is correct
12 Correct 109 ms 6576 KB Output is correct
13 Correct 35 ms 5132 KB Output is correct
14 Correct 29 ms 5132 KB Output is correct
15 Runtime error 383 ms 262148 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -