Submission #280380

# Submission time Handle Problem Language Result Execution time Memory
280380 2020-08-22T17:04:18 Z _7_7_ Wombats (IOI13_wombats) C++14
9 / 100
4187 ms 94556 KB
#include "wombats.h"
#include <bits/stdc++.h>                                           
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
 
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 1012;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;


int h[5000][200], v[5000][200], n = 5000, m = 200, L = 20, bl = n / L, opt[200][200];
int t[2000][200][200];
 
void update (int pos, int v = 1, int tl = 0, int tr = bl - 1) {
	if (tl == tr) {
		for (int j = 0; j < m; ++j)
			for (int x = 0; x < m; ++x)
				t[v][j][x] = inf*2;
		
		for (int j = 0; j < m; ++j) {
			t[v][j][j] = 0;
			for (int i = tl*L; i < (tl + 1)*L ; ++i) {
				for (int x = 0; x + 1 < m; ++x)
					t[v][j][x + 1] = min(t[v][j][x + 1], t[v][j][x] + h[i][x]);
				
				for (int x = m - 1; x > 0; --x)
					t[v][j][x - 1] = min(t[v][j][x - 1], t[v][j][x] + h[i][x - 1]);

				for (int x = 0; x < m; ++x) 
					t[v][j][x] += ::v[i][x]; 				
			}
		}

		return;
	}

	int tm = (tl + tr) >> 1;
	if (pos <= tm)
		update(pos, v << 1, tl, tm);
	else
		update(pos, v << 1 | 1, tm + 1, tr);
	
	for (int i = 0; i < m; ++i)	
		for (int j = m - 1; j >= 0; --j) {
 			int optl = !i ? 0 : opt[i - 1][j], optr = j == m - 1 ? m - 1 : opt[i][j + 1];
			t[v][i][j] = inf*2;

			for (int x = optl; x <= optr; ++x)
				if (t[v][i][j] > t[v << 1][i][x] + t[v << 1 | 1][x][j]) {
					t[v][i][j] = t[v << 1][i][x] + t[v << 1 | 1][x][j];
					opt[i][j] = x;
				}
		}
}

void init(int r, int c, int H[5000][200], int V[5000][200]) {
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			h[i][j] = inf;
			v[i][j] = 0;
			if (i < r && j + 1 < c)
				h[i][j] = H[i][j];
			if (i + 1 < r && j < c)
				v[i][j] = V[i][j];
		}

	for (int i = 0; i < bl; ++i)
		update(i);
}
 
void changeH(int p, int q, int w) {
	h[p][q] = w;
	update(p / L);
}
 
void changeV(int p, int q, int w) {
	v[p][q] = w;
	update(p / L);
}
 
int escape(int a, int b) {
	return t[1][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]
   15 |  int res;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 3901 ms 90692 KB Output is correct
2 Correct 3688 ms 90452 KB Output is correct
3 Correct 3852 ms 92012 KB Output is correct
4 Correct 3723 ms 90488 KB Output is correct
5 Correct 3671 ms 90620 KB Output is correct
6 Correct 1212 ms 86520 KB Output is correct
7 Correct 1221 ms 86520 KB Output is correct
8 Correct 1261 ms 86612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1283 ms 86520 KB Output is correct
2 Correct 1208 ms 86520 KB Output is correct
3 Correct 1264 ms 86520 KB Output is correct
4 Incorrect 1222 ms 86664 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1899 ms 86696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4187 ms 94556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1936 ms 86704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1906 ms 86664 KB Output isn't correct
2 Halted 0 ms 0 KB -