Submission #966903

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

// author : a1abay

#define all(v)      v.begin(), v.end()
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   (a*b / (__gcd(a, b)))
#define int         ll

typedef long long           ll;
typedef long double         ld;
const int inf =             1e9 + 7;
const int inff =            (int)1e18 + 7;
const int sz =              5e3 + 5;
using namespace             std;

int n, m, l, r, k, v;
vector<array<int, 3>> e;
vector<int> d(sz, inf);

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

    cin >> n >> m;
    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 496 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 492 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 1368 KB Output is correct
2 Correct 103 ms 1364 KB Output is correct
3 Correct 105 ms 1368 KB Output is correct
4 Correct 100 ms 1368 KB Output is correct
5 Correct 261 ms 1364 KB Output is correct
6 Correct 248 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 1368 KB Output is correct
2 Correct 103 ms 1364 KB Output is correct
3 Correct 105 ms 1368 KB Output is correct
4 Correct 100 ms 1368 KB Output is correct
5 Correct 261 ms 1364 KB Output is correct
6 Correct 248 ms 1368 KB Output is correct
7 Correct 103 ms 1364 KB Output is correct
8 Correct 100 ms 1368 KB Output is correct
9 Correct 104 ms 1364 KB Output is correct
10 Correct 98 ms 1368 KB Output is correct
11 Correct 321 ms 1368 KB Output is correct
12 Correct 330 ms 1620 KB Output is correct
13 Correct 99 ms 1364 KB Output is correct
14 Correct 105 ms 1368 KB Output is correct
15 Correct 116 ms 1368 KB Output is correct
16 Correct 125 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 496 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 492 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 117 ms 1368 KB Output is correct
12 Correct 103 ms 1364 KB Output is correct
13 Correct 105 ms 1368 KB Output is correct
14 Correct 100 ms 1368 KB Output is correct
15 Correct 261 ms 1364 KB Output is correct
16 Correct 248 ms 1368 KB Output is correct
17 Correct 103 ms 1364 KB Output is correct
18 Correct 100 ms 1368 KB Output is correct
19 Correct 104 ms 1364 KB Output is correct
20 Correct 98 ms 1368 KB Output is correct
21 Correct 321 ms 1368 KB Output is correct
22 Correct 330 ms 1620 KB Output is correct
23 Correct 99 ms 1364 KB Output is correct
24 Correct 105 ms 1368 KB Output is correct
25 Correct 116 ms 1368 KB Output is correct
26 Correct 125 ms 1368 KB Output is correct
27 Correct 102 ms 1368 KB Output is correct
28 Correct 101 ms 1368 KB Output is correct
29 Correct 104 ms 1364 KB Output is correct
30 Correct 101 ms 1364 KB Output is correct
31 Correct 96 ms 1368 KB Output is correct
32 Correct 101 ms 1368 KB Output is correct
33 Correct 272 ms 1364 KB Output is correct
34 Correct 315 ms 1368 KB Output is correct
35 Correct 101 ms 1364 KB Output is correct
36 Correct 108 ms 1576 KB Output is correct