Submission #966910

# Submission time Handle Problem Language Result Execution time Memory
966910 2024-04-20T15:20:32 Z AtabayRajabli Restore Array (RMI19_restore) C++17
100 / 100
319 ms 852 KB
#include <bits/stdc++.h>

// author : a1abay

using namespace             std;

int n, m, l, r, k, v;
vector<array<int, 3>> e;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    vector<int> d(n + 1, n + 1);
    for(int i = 0; i < n; i++)
    {
        e.push_back({i, i + 1, 1});
        e.push_back({i + 1, i, 0});
    }
    while(m--)
    {
        cin >> l >> r >> k >> v;
        if(!v) e.push_back({l, r + 1, r - l + 1 - k});
        else e.push_back({r + 1, l, -(r - l + 1 - k + 1)});
    }
    d[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(auto p : e)
        {
            if(d[p[0]] + p[2] < d[p[1]])
            {
                d[p[1]] = d[p[0]] + p[2];
                if(i == n)
                {
                    cout << -1;
                    return 0;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) cout << d[i] - d[i - 1] << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 796 KB Output is correct
2 Correct 99 ms 824 KB Output is correct
3 Correct 98 ms 796 KB Output is correct
4 Correct 104 ms 852 KB Output is correct
5 Correct 252 ms 796 KB Output is correct
6 Correct 246 ms 796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 796 KB Output is correct
2 Correct 99 ms 824 KB Output is correct
3 Correct 98 ms 796 KB Output is correct
4 Correct 104 ms 852 KB Output is correct
5 Correct 252 ms 796 KB Output is correct
6 Correct 246 ms 796 KB Output is correct
7 Correct 123 ms 824 KB Output is correct
8 Correct 106 ms 796 KB Output is correct
9 Correct 101 ms 828 KB Output is correct
10 Correct 99 ms 792 KB Output is correct
11 Correct 315 ms 792 KB Output is correct
12 Correct 319 ms 792 KB Output is correct
13 Correct 100 ms 796 KB Output is correct
14 Correct 104 ms 796 KB Output is correct
15 Correct 102 ms 796 KB Output is correct
16 Correct 111 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 100 ms 796 KB Output is correct
12 Correct 99 ms 824 KB Output is correct
13 Correct 98 ms 796 KB Output is correct
14 Correct 104 ms 852 KB Output is correct
15 Correct 252 ms 796 KB Output is correct
16 Correct 246 ms 796 KB Output is correct
17 Correct 123 ms 824 KB Output is correct
18 Correct 106 ms 796 KB Output is correct
19 Correct 101 ms 828 KB Output is correct
20 Correct 99 ms 792 KB Output is correct
21 Correct 315 ms 792 KB Output is correct
22 Correct 319 ms 792 KB Output is correct
23 Correct 100 ms 796 KB Output is correct
24 Correct 104 ms 796 KB Output is correct
25 Correct 102 ms 796 KB Output is correct
26 Correct 111 ms 852 KB Output is correct
27 Correct 122 ms 832 KB Output is correct
28 Correct 104 ms 792 KB Output is correct
29 Correct 101 ms 796 KB Output is correct
30 Correct 109 ms 796 KB Output is correct
31 Correct 97 ms 812 KB Output is correct
32 Correct 98 ms 820 KB Output is correct
33 Correct 262 ms 796 KB Output is correct
34 Correct 301 ms 796 KB Output is correct
35 Correct 101 ms 792 KB Output is correct
36 Correct 99 ms 792 KB Output is correct