Submission #280382

# Submission time Handle Problem Language Result Execution time Memory
280382 2020-08-22T17:06:18 Z _7_7_ Wombats (IOI13_wombats) C++14
100 / 100
4699 ms 178680 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];
ll 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;
		
		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;

			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*2;
			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 4090 ms 168560 KB Output is correct
2 Correct 4080 ms 168572 KB Output is correct
3 Correct 4164 ms 170208 KB Output is correct
4 Correct 4050 ms 168568 KB Output is correct
5 Correct 4017 ms 168440 KB Output is correct
6 Correct 1340 ms 164728 KB Output is correct
7 Correct 1357 ms 164512 KB Output is correct
8 Correct 1355 ms 164600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1381 ms 164668 KB Output is correct
2 Correct 1382 ms 164628 KB Output is correct
3 Correct 1396 ms 164716 KB Output is correct
4 Correct 1355 ms 164728 KB Output is correct
5 Correct 1342 ms 164728 KB Output is correct
6 Correct 1342 ms 164644 KB Output is correct
7 Correct 1336 ms 164728 KB Output is correct
8 Correct 1386 ms 164624 KB Output is correct
9 Correct 1341 ms 164600 KB Output is correct
10 Correct 1361 ms 164656 KB Output is correct
11 Correct 1440 ms 166504 KB Output is correct
12 Correct 1331 ms 164600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1889 ms 164724 KB Output is correct
2 Correct 1918 ms 164880 KB Output is correct
3 Correct 1873 ms 164856 KB Output is correct
4 Correct 1905 ms 164924 KB Output is correct
5 Correct 1882 ms 165112 KB Output is correct
6 Correct 1342 ms 164668 KB Output is correct
7 Correct 1343 ms 164728 KB Output is correct
8 Correct 1352 ms 164672 KB Output is correct
9 Correct 4239 ms 164876 KB Output is correct
10 Correct 1417 ms 164640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4019 ms 172592 KB Output is correct
2 Correct 4145 ms 172744 KB Output is correct
3 Correct 4147 ms 172520 KB Output is correct
4 Correct 4135 ms 173972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1912 ms 164748 KB Output is correct
2 Correct 1908 ms 164976 KB Output is correct
3 Correct 1916 ms 164900 KB Output is correct
4 Correct 1943 ms 164896 KB Output is correct
5 Correct 1933 ms 164864 KB Output is correct
6 Correct 4062 ms 172660 KB Output is correct
7 Correct 4075 ms 172544 KB Output is correct
8 Correct 4172 ms 172724 KB Output is correct
9 Correct 4130 ms 174136 KB Output is correct
10 Correct 4075 ms 168568 KB Output is correct
11 Correct 4105 ms 168672 KB Output is correct
12 Correct 4130 ms 170852 KB Output is correct
13 Correct 4094 ms 168636 KB Output is correct
14 Correct 4075 ms 168644 KB Output is correct
15 Correct 1362 ms 164732 KB Output is correct
16 Correct 1337 ms 164600 KB Output is correct
17 Correct 1354 ms 164600 KB Output is correct
18 Correct 1358 ms 164728 KB Output is correct
19 Correct 1365 ms 164680 KB Output is correct
20 Correct 1388 ms 164572 KB Output is correct
21 Correct 1342 ms 164728 KB Output is correct
22 Correct 1373 ms 164600 KB Output is correct
23 Correct 1350 ms 164600 KB Output is correct
24 Correct 1345 ms 164600 KB Output is correct
25 Correct 1430 ms 166264 KB Output is correct
26 Correct 1340 ms 164728 KB Output is correct
27 Correct 4120 ms 164948 KB Output is correct
28 Correct 4105 ms 174572 KB Output is correct
29 Correct 4240 ms 174244 KB Output is correct
30 Correct 4236 ms 174348 KB Output is correct
31 Correct 4246 ms 176616 KB Output is correct
32 Correct 1388 ms 164856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1879 ms 164708 KB Output is correct
2 Correct 1862 ms 165088 KB Output is correct
3 Correct 1884 ms 164992 KB Output is correct
4 Correct 1944 ms 165156 KB Output is correct
5 Correct 1924 ms 164856 KB Output is correct
6 Correct 4083 ms 172536 KB Output is correct
7 Correct 4005 ms 172540 KB Output is correct
8 Correct 4027 ms 172640 KB Output is correct
9 Correct 4210 ms 174120 KB Output is correct
10 Correct 4218 ms 168572 KB Output is correct
11 Correct 4070 ms 168772 KB Output is correct
12 Correct 4377 ms 170844 KB Output is correct
13 Correct 4502 ms 168652 KB Output is correct
14 Correct 4372 ms 168556 KB Output is correct
15 Correct 1651 ms 173948 KB Output is correct
16 Correct 4547 ms 176288 KB Output is correct
17 Correct 1383 ms 164600 KB Output is correct
18 Correct 1362 ms 164536 KB Output is correct
19 Correct 1349 ms 164576 KB Output is correct
20 Correct 1349 ms 164572 KB Output is correct
21 Correct 1389 ms 164644 KB Output is correct
22 Correct 1438 ms 164600 KB Output is correct
23 Correct 1410 ms 164600 KB Output is correct
24 Correct 1407 ms 164632 KB Output is correct
25 Correct 1354 ms 164580 KB Output is correct
26 Correct 1350 ms 164728 KB Output is correct
27 Correct 1433 ms 167032 KB Output is correct
28 Correct 1400 ms 164728 KB Output is correct
29 Correct 3977 ms 164856 KB Output is correct
30 Correct 4046 ms 176504 KB Output is correct
31 Correct 4014 ms 177976 KB Output is correct
32 Correct 3975 ms 177956 KB Output is correct
33 Correct 4089 ms 174840 KB Output is correct
34 Correct 4368 ms 176768 KB Output is correct
35 Correct 4163 ms 174848 KB Output is correct
36 Correct 4397 ms 176760 KB Output is correct
37 Correct 4375 ms 178296 KB Output is correct
38 Correct 4109 ms 178680 KB Output is correct
39 Correct 1382 ms 164604 KB Output is correct
40 Correct 4699 ms 176624 KB Output is correct