답안 #966909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966909 2024-04-20T15:19:58 Z AtabayRajabli Restore Array (RMI19_restore) C++17
20 / 100
318 ms 1356 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, n);
    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] << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 796 KB Output is correct
2 Correct 101 ms 792 KB Output is correct
3 Correct 102 ms 820 KB Output is correct
4 Correct 99 ms 792 KB Output is correct
5 Correct 251 ms 796 KB Output is correct
6 Correct 247 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 796 KB Output is correct
2 Correct 101 ms 792 KB Output is correct
3 Correct 102 ms 820 KB Output is correct
4 Correct 99 ms 792 KB Output is correct
5 Correct 251 ms 796 KB Output is correct
6 Correct 247 ms 792 KB Output is correct
7 Correct 103 ms 796 KB Output is correct
8 Correct 103 ms 792 KB Output is correct
9 Correct 111 ms 820 KB Output is correct
10 Correct 103 ms 792 KB Output is correct
11 Correct 309 ms 792 KB Output is correct
12 Runtime error 318 ms 1356 KB Execution killed with signal 6
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
11 Correct 98 ms 796 KB Output is correct
12 Correct 101 ms 792 KB Output is correct
13 Correct 102 ms 820 KB Output is correct
14 Correct 99 ms 792 KB Output is correct
15 Correct 251 ms 796 KB Output is correct
16 Correct 247 ms 792 KB Output is correct
17 Correct 103 ms 796 KB Output is correct
18 Correct 103 ms 792 KB Output is correct
19 Correct 111 ms 820 KB Output is correct
20 Correct 103 ms 792 KB Output is correct
21 Correct 309 ms 792 KB Output is correct
22 Runtime error 318 ms 1356 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -