답안 #961121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961121 2024-04-11T14:14:17 Z blacktulip Restore Array (RMI19_restore) C++17
100 / 100
319 ms 1304 KB
#include <bits/stdc++.h>
using namespace std;
 
const int MXN = 5e3 + 5;
 
int n, m;
vector<array<int, 3>> ed;
int dist[MXN];
 
int add(int a, int b)
{
    return a + b;
}
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        ed.push_back({i, add(i, 1), 1});
        ed.push_back({add(i, 1), i, 0});
    }
    for (int i = 1; i <= n; i++) dist[i] = add(n, 10);
    while (m--)
    {
        int l, r, k, v;
        cin >> l >> r >> k >> v;
        r++;
        int sz = r - l;
        if (v == 1)
        {
            int mx = sz;
            int mn = sz - k + 1;
            ed.push_back({r, l, (int)(-mn)});
        }
        else
        {
            int mn = 0;
            int mx = sz - k;
            ed.push_back({l, r, mx});
        }
    }
    bool f = 0;
    for (int i = 1; i <= n + 1; i++)
    {
        f = 0;
        for (const array<int, 3> &x : ed)
        {
            if (add(dist[x[0]], x[2]) < dist[x[1]]) 
            {
                f = 1;
                dist[x[1]] = add(dist[x[0]], x[2]);
            }
        }
    }
    if (f)
    {
        cout << -1 << '\n';
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << dist[i] - dist[i - 1] << ' ';
    }
    cout << '\n';
}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:34:17: warning: unused variable 'mx' [-Wunused-variable]
   34 |             int mx = sz;
      |                 ^~
restore.cpp:40:17: warning: unused variable 'mn' [-Wunused-variable]
   40 |             int mn = 0;
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 388 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 1304 KB Output is correct
2 Correct 80 ms 1052 KB Output is correct
3 Correct 83 ms 1052 KB Output is correct
4 Correct 78 ms 1048 KB Output is correct
5 Correct 236 ms 1052 KB Output is correct
6 Correct 222 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 1304 KB Output is correct
2 Correct 80 ms 1052 KB Output is correct
3 Correct 83 ms 1052 KB Output is correct
4 Correct 78 ms 1048 KB Output is correct
5 Correct 236 ms 1052 KB Output is correct
6 Correct 222 ms 1048 KB Output is correct
7 Correct 80 ms 1048 KB Output is correct
8 Correct 85 ms 1052 KB Output is correct
9 Correct 82 ms 1008 KB Output is correct
10 Correct 81 ms 1052 KB Output is correct
11 Correct 314 ms 1048 KB Output is correct
12 Correct 319 ms 1048 KB Output is correct
13 Correct 77 ms 1116 KB Output is correct
14 Correct 91 ms 1048 KB Output is correct
15 Correct 83 ms 1052 KB Output is correct
16 Correct 90 ms 1300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 388 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 79 ms 1304 KB Output is correct
12 Correct 80 ms 1052 KB Output is correct
13 Correct 83 ms 1052 KB Output is correct
14 Correct 78 ms 1048 KB Output is correct
15 Correct 236 ms 1052 KB Output is correct
16 Correct 222 ms 1048 KB Output is correct
17 Correct 80 ms 1048 KB Output is correct
18 Correct 85 ms 1052 KB Output is correct
19 Correct 82 ms 1008 KB Output is correct
20 Correct 81 ms 1052 KB Output is correct
21 Correct 314 ms 1048 KB Output is correct
22 Correct 319 ms 1048 KB Output is correct
23 Correct 77 ms 1116 KB Output is correct
24 Correct 91 ms 1048 KB Output is correct
25 Correct 83 ms 1052 KB Output is correct
26 Correct 90 ms 1300 KB Output is correct
27 Correct 79 ms 1052 KB Output is correct
28 Correct 79 ms 1052 KB Output is correct
29 Correct 82 ms 1052 KB Output is correct
30 Correct 79 ms 1052 KB Output is correct
31 Correct 79 ms 1108 KB Output is correct
32 Correct 77 ms 1048 KB Output is correct
33 Correct 238 ms 1052 KB Output is correct
34 Correct 293 ms 1052 KB Output is correct
35 Correct 93 ms 1048 KB Output is correct
36 Correct 79 ms 1248 KB Output is correct