# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
312797 | BeanZ | Restore Array (RMI19_restore) | C++14 | 379 ms | 1404 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 5005;
struct viet{
ll u, v, c;
};
ll d[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) d[i] = i;
vector<viet> E;
for (int i = 1; i <= m; i++){
ll l, r, k, v;
cin >> l >> r >> k >> v;
l++;
r++;
if (v == 1){
E.push_back({r, l - 1, -(r - l + 1 - k + 1)});
} else {
// S(r) - S(l - 1) <= (r - l + 1 - k)
E.push_back({l - 1, r, r - l + 1 - k});
}
}
for (int i = 1; i <= n; i++){
E.push_back({i - 1, i, 1});
E.push_back({i, i - 1, 0});
}
ll x;
for (int i = 1; i <= n; i++){
x = -1;
for (auto j : E){
if (d[j.v] > (d[j.u] + j.c)){
d[j.v] = d[j.u] + j.c;
x = j.v;
}
}
}
if (x != -1) cout << -1;
else {
for (int i = 1; i <= n; i++){
//cout << d[i] << " ";
if (d[i] > d[i - 1]) cout << 1 << " ";
else cout << 0 << " ";
}
}
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |