답안 #625449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625449 2022-08-10T12:04:49 Z model_code 송신탑 (IOI22_towers) C++17
11 / 100
2500 ms 3380 KB
// failed/solution-fausta-tle-optimized.cpp
#include "towers.h"

#include <vector>

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int NN = 2e5 + 5;
int ma = 0, k, a[NN], n, kan[NN], nx[NN], d[NN], m;
int ST[4 * NN];
int BIT[3 * NN];

map<int, int> me;

void upd(int L, int R, int x, int y, int idx)
{
	if(L == R)
	{
		ST[idx] = y;
	}
	else
	{
		int C = (L + R) / 2;
		if(x <= C)
			upd(L, C, x, y, idx * 2);
		else
			upd(C + 1, R, x, y, idx * 2 + 1);
		ST[idx] = min(ST[idx * 2], ST[idx * 2 + 1]);
	}
}

int cari(int L, int R, int z, int idx)
{
	// cout << L << " " << R << " " << z << " " << idx << "__\n";
	if(L == R)
		return L;
	else
	{
		int C = (L + R) / 2;
		// cout << ST[idx * 2] << " dan " << z << "\n";
		if(ST[idx * 2] <= z)
			return cari(L, C, z, idx * 2);
		else
			return cari(C + 1, R, z, idx * 2 + 1);
	}
}


void init(int N, std::vector<int> H) {
	n = N;
	for(int i = 0; i < N; i++)
	{
		a[i + 1] = H[i];
	}
}

int max_towers(int L, int R, int D) {
	L++;
	R++;
	for(int i = L; i <= R; i++)
		upd(L, R, i, a[i], 1);
	for(int i = L; i <= R; i++)
	{
		upd(L, R, i, 1e9, 1);
		if(ST[1] > a[i] - D)
			kan[i] = R + 1;
		else
			kan[i] = cari(L, R, a[i] - D, 1);
	}
	for(int i = L; i <= R; i++)
	{
		nx[i] = R + 1;
		for(int j = i + 1; j <= min((int)R, i + 2000); j++)
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		for(int j = max(i + 1, (i+1+R)/2 - 2000); j <= min((int)R, (i+1+R)/2 + 2000); j++)
		{
			if(j > nx[i])
				break;
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		}
		for(int j = max(i + 1, (int)R - 2000); j <= R; j++)
		{
			if(j > nx[i])
				break;
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		}
	}
	d[R + 1] = 0;
	for(int i = R; i >= L; i--)
		d[i] = max(d[i + 1], 1 + d[nx[i]]);
	return d[L];
}


/*
7 1
10 20 60 30 50 40 70
1 5 10

7 3
10 20 60 30 50 40 70
1 5 10
2 2 100
0 6 17
*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 1956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 11 ms 336 KB Output is correct
24 Correct 14 ms 440 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 6 ms 372 KB Output is correct
27 Correct 7 ms 380 KB Output is correct
28 Correct 10 ms 384 KB Output is correct
29 Correct 11 ms 388 KB Output is correct
30 Correct 11 ms 388 KB Output is correct
31 Correct 11 ms 388 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 11 ms 364 KB Output is correct
35 Correct 7 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 11 ms 336 KB Output is correct
24 Correct 14 ms 440 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 6 ms 372 KB Output is correct
27 Correct 7 ms 380 KB Output is correct
28 Correct 10 ms 384 KB Output is correct
29 Correct 11 ms 388 KB Output is correct
30 Correct 11 ms 388 KB Output is correct
31 Correct 11 ms 388 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 11 ms 364 KB Output is correct
35 Correct 7 ms 360 KB Output is correct
36 Correct 153 ms 1204 KB Output is correct
37 Correct 381 ms 1972 KB Output is correct
38 Correct 141 ms 1460 KB Output is correct
39 Correct 255 ms 1656 KB Output is correct
40 Correct 103 ms 1464 KB Output is correct
41 Correct 585 ms 3120 KB Output is correct
42 Correct 27 ms 1488 KB Output is correct
43 Correct 976 ms 2204 KB Output is correct
44 Correct 115 ms 1504 KB Output is correct
45 Correct 30 ms 1464 KB Output is correct
46 Correct 22 ms 1444 KB Output is correct
47 Correct 290 ms 2016 KB Output is correct
48 Correct 132 ms 1616 KB Output is correct
49 Correct 51 ms 1536 KB Output is correct
50 Correct 237 ms 1524 KB Output is correct
51 Correct 1060 ms 2024 KB Output is correct
52 Correct 744 ms 3220 KB Output is correct
53 Correct 601 ms 3288 KB Output is correct
54 Correct 562 ms 3296 KB Output is correct
55 Correct 1323 ms 3284 KB Output is correct
56 Correct 1792 ms 3224 KB Output is correct
57 Correct 1000 ms 3200 KB Output is correct
58 Correct 812 ms 3288 KB Output is correct
59 Correct 704 ms 3284 KB Output is correct
60 Correct 560 ms 3232 KB Output is correct
61 Correct 633 ms 3280 KB Output is correct
62 Correct 759 ms 3284 KB Output is correct
63 Correct 611 ms 3284 KB Output is correct
64 Correct 1175 ms 3232 KB Output is correct
65 Correct 1012 ms 3276 KB Output is correct
66 Incorrect 1830 ms 3380 KB 1st lines differ - on the 1st token, expected: '5', found: '3'
67 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3025 ms 3124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 1104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 9 ms 336 KB Output is correct
21 Correct 9 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 11 ms 336 KB Output is correct
24 Correct 14 ms 440 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 6 ms 372 KB Output is correct
27 Correct 7 ms 380 KB Output is correct
28 Correct 10 ms 384 KB Output is correct
29 Correct 11 ms 388 KB Output is correct
30 Correct 11 ms 388 KB Output is correct
31 Correct 11 ms 388 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 11 ms 364 KB Output is correct
35 Correct 7 ms 360 KB Output is correct
36 Correct 153 ms 1204 KB Output is correct
37 Correct 381 ms 1972 KB Output is correct
38 Correct 141 ms 1460 KB Output is correct
39 Correct 255 ms 1656 KB Output is correct
40 Correct 103 ms 1464 KB Output is correct
41 Correct 585 ms 3120 KB Output is correct
42 Correct 27 ms 1488 KB Output is correct
43 Correct 976 ms 2204 KB Output is correct
44 Correct 115 ms 1504 KB Output is correct
45 Correct 30 ms 1464 KB Output is correct
46 Correct 22 ms 1444 KB Output is correct
47 Correct 290 ms 2016 KB Output is correct
48 Correct 132 ms 1616 KB Output is correct
49 Correct 51 ms 1536 KB Output is correct
50 Correct 237 ms 1524 KB Output is correct
51 Correct 1060 ms 2024 KB Output is correct
52 Correct 744 ms 3220 KB Output is correct
53 Correct 601 ms 3288 KB Output is correct
54 Correct 562 ms 3296 KB Output is correct
55 Correct 1323 ms 3284 KB Output is correct
56 Correct 1792 ms 3224 KB Output is correct
57 Correct 1000 ms 3200 KB Output is correct
58 Correct 812 ms 3288 KB Output is correct
59 Correct 704 ms 3284 KB Output is correct
60 Correct 560 ms 3232 KB Output is correct
61 Correct 633 ms 3280 KB Output is correct
62 Correct 759 ms 3284 KB Output is correct
63 Correct 611 ms 3284 KB Output is correct
64 Correct 1175 ms 3232 KB Output is correct
65 Correct 1012 ms 3276 KB Output is correct
66 Incorrect 1830 ms 3380 KB 1st lines differ - on the 1st token, expected: '5', found: '3'
67 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 1956 KB Time limit exceeded
2 Halted 0 ms 0 KB -