답안 #835339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835339 2023-08-23T13:29:14 Z SamAnd 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 4392 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 100005;

int n, d;
int a[N];

int ul[N], ur[N];
vector<pair<pair<int, int>, int> > b;

bool sos(const pair<pair<int, int>, int>& a, const pair<pair<int, int>, int>& b)
{
    return a.fi.se < b.fi.se;
}

void pre()
{
    b.clear();

    vector<int> s;
    for (int i = 1; i <= n; ++i)
    {
        while (!s.empty() && a[s.back()] <= a[i])
            s.pop_back();
        s.push_back(i);

        int l = 0, r = sz(s) - 1;
        ul[i] = 0;
        while (l <= r)
        {
            int m = (l + r) / 2;
            if (a[s[m]] - d >= a[i])
            {
                ul[i] = s[m];
                l = m + 1;
            }
            else
            {
                r = m - 1;
            }
        }
    }
    s.clear();
    for (int i = n; i >= 1; --i)
    {
        while (!s.empty() && a[s.back()] <= a[i])
            s.pop_back();
        s.push_back(i);

        int l = 0, r = sz(s) - 1;
        ur[i] = n + 1;
        while (l <= r)
        {
            int m = (l + r) / 2;
            if (a[s[m]] - d >= a[i])
            {
                ur[i] = s[m];
                l = m + 1;
            }
            else
                r = m - 1;
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        b.push_back(m_p(m_p(ul[i] + 1, ur[i] - 1), i));
    }
    sort(all(b), sos);
}

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

int max_towers(int L, int R, int D)
{
    ++L;
    ++R;
    if (b.empty())
    {
        d = D;
        pre();
    }

    int ans = 0;
    int u = 0;
    for (int i = 0; i < n; ++i)
    {
        if (L <= b[i].se && b[i].se <= R)
        {
            if (b[i].fi.fi > u)
            {
                u = b[i].fi.se;
                ++ans;
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2626 ms 2328 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 17 ms 2208 KB Output is correct
37 Correct 21 ms 3500 KB Output is correct
38 Correct 20 ms 3520 KB Output is correct
39 Correct 21 ms 3520 KB Output is correct
40 Correct 20 ms 3504 KB Output is correct
41 Correct 18 ms 3492 KB Output is correct
42 Correct 24 ms 3492 KB Output is correct
43 Correct 18 ms 3872 KB Output is correct
44 Correct 17 ms 3904 KB Output is correct
45 Correct 16 ms 3784 KB Output is correct
46 Correct 22 ms 4392 KB Output is correct
47 Correct 19 ms 3496 KB Output is correct
48 Correct 18 ms 3472 KB Output is correct
49 Correct 21 ms 3492 KB Output is correct
50 Correct 16 ms 3872 KB Output is correct
51 Correct 17 ms 3912 KB Output is correct
52 Correct 20 ms 3504 KB Output is correct
53 Correct 18 ms 3528 KB Output is correct
54 Correct 18 ms 3528 KB Output is correct
55 Correct 16 ms 3992 KB Output is correct
56 Correct 22 ms 3784 KB Output is correct
57 Correct 19 ms 3784 KB Output is correct
58 Correct 20 ms 3520 KB Output is correct
59 Correct 26 ms 3508 KB Output is correct
60 Correct 21 ms 3520 KB Output is correct
61 Correct 20 ms 3480 KB Output is correct
62 Correct 19 ms 3500 KB Output is correct
63 Correct 20 ms 3524 KB Output is correct
64 Correct 18 ms 3896 KB Output is correct
65 Correct 16 ms 3900 KB Output is correct
66 Correct 18 ms 4388 KB Output is correct
67 Correct 22 ms 3912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4048 ms 3532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2420 ms 1172 KB 2nd lines differ - on the 1st token, expected: '7063', found: '7197'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 17 ms 2208 KB Output is correct
37 Correct 21 ms 3500 KB Output is correct
38 Correct 20 ms 3520 KB Output is correct
39 Correct 21 ms 3520 KB Output is correct
40 Correct 20 ms 3504 KB Output is correct
41 Correct 18 ms 3492 KB Output is correct
42 Correct 24 ms 3492 KB Output is correct
43 Correct 18 ms 3872 KB Output is correct
44 Correct 17 ms 3904 KB Output is correct
45 Correct 16 ms 3784 KB Output is correct
46 Correct 22 ms 4392 KB Output is correct
47 Correct 19 ms 3496 KB Output is correct
48 Correct 18 ms 3472 KB Output is correct
49 Correct 21 ms 3492 KB Output is correct
50 Correct 16 ms 3872 KB Output is correct
51 Correct 17 ms 3912 KB Output is correct
52 Correct 20 ms 3504 KB Output is correct
53 Correct 18 ms 3528 KB Output is correct
54 Correct 18 ms 3528 KB Output is correct
55 Correct 16 ms 3992 KB Output is correct
56 Correct 22 ms 3784 KB Output is correct
57 Correct 19 ms 3784 KB Output is correct
58 Correct 20 ms 3520 KB Output is correct
59 Correct 26 ms 3508 KB Output is correct
60 Correct 21 ms 3520 KB Output is correct
61 Correct 20 ms 3480 KB Output is correct
62 Correct 19 ms 3500 KB Output is correct
63 Correct 20 ms 3524 KB Output is correct
64 Correct 18 ms 3896 KB Output is correct
65 Correct 16 ms 3900 KB Output is correct
66 Correct 18 ms 4388 KB Output is correct
67 Correct 22 ms 3912 KB Output is correct
68 Execution timed out 4048 ms 3532 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2626 ms 2328 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -