답안 #332473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332473 2020-12-02T16:27:26 Z IgorI Restore Array (RMI19_restore) C++17
100 / 100
520 ms 876 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 20300;

int f[N], t[N], w[N];
int sz;
int d[N];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int l, r, k, v;
        cin >> l >> r >> k >> v;
        r++;
        if (v == 0)
        {
            // k-th = zero, at most len-k ones
            f[sz] = l;
            t[sz] = r;
            w[sz] = r - l - k;
            sz++;
        }
        else
        {
            // k-th = one, at least len - k + 1 ones
            f[sz] = r;
            t[sz] = l;
            w[sz] = -(r - l - k + 1);
            sz++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        f[sz] = i;
        t[sz] = i + 1;
        w[sz] = 1;
        sz++;
    }
    for (int i = 1; i <= n; i++)
    {
        d[i] = 1e9;

        f[sz] = i;
        t[sz] = i - 1;
        w[sz] = 0;
        sz++;
    }
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j < sz; j++)
        {
            if (d[f[j]] + w[j] < d[t[j]])
            {
                d[t[j]] = d[f[j]] + w[j];
            }
        }
    }
    for (int j = 0; j < sz; j++)
    {
        if (d[f[j]] + w[j] < d[t[j]])
        {
            cout << -1;
            return 0;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << d[i] - d[i - 1] << " ";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 620 KB Output is correct
2 Correct 163 ms 620 KB Output is correct
3 Correct 162 ms 748 KB Output is correct
4 Correct 187 ms 748 KB Output is correct
5 Correct 505 ms 876 KB Output is correct
6 Correct 505 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 620 KB Output is correct
2 Correct 163 ms 620 KB Output is correct
3 Correct 162 ms 748 KB Output is correct
4 Correct 187 ms 748 KB Output is correct
5 Correct 505 ms 876 KB Output is correct
6 Correct 505 ms 876 KB Output is correct
7 Correct 165 ms 876 KB Output is correct
8 Correct 173 ms 876 KB Output is correct
9 Correct 166 ms 780 KB Output is correct
10 Correct 166 ms 772 KB Output is correct
11 Correct 494 ms 748 KB Output is correct
12 Correct 500 ms 748 KB Output is correct
13 Correct 170 ms 748 KB Output is correct
14 Correct 167 ms 748 KB Output is correct
15 Correct 172 ms 748 KB Output is correct
16 Correct 187 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 171 ms 620 KB Output is correct
12 Correct 163 ms 620 KB Output is correct
13 Correct 162 ms 748 KB Output is correct
14 Correct 187 ms 748 KB Output is correct
15 Correct 505 ms 876 KB Output is correct
16 Correct 505 ms 876 KB Output is correct
17 Correct 165 ms 876 KB Output is correct
18 Correct 173 ms 876 KB Output is correct
19 Correct 166 ms 780 KB Output is correct
20 Correct 166 ms 772 KB Output is correct
21 Correct 494 ms 748 KB Output is correct
22 Correct 500 ms 748 KB Output is correct
23 Correct 170 ms 748 KB Output is correct
24 Correct 167 ms 748 KB Output is correct
25 Correct 172 ms 748 KB Output is correct
26 Correct 187 ms 748 KB Output is correct
27 Correct 158 ms 876 KB Output is correct
28 Correct 164 ms 876 KB Output is correct
29 Correct 166 ms 748 KB Output is correct
30 Correct 169 ms 876 KB Output is correct
31 Correct 159 ms 772 KB Output is correct
32 Correct 164 ms 876 KB Output is correct
33 Correct 520 ms 876 KB Output is correct
34 Correct 493 ms 876 KB Output is correct
35 Correct 162 ms 788 KB Output is correct
36 Correct 163 ms 876 KB Output is correct