# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
272401 | eohomegrownapps | Restore Array (RMI19_restore) | C++14 | 227 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int INF = 1e9;
void relaxedges(){
int a[15001], b[15001], c[15001];
for (int i = 0; i<m; i++){
int l,r,k,v;
cin>>l>>r>>k>>v;
r++;
if (v==0){
a[i]=l;
b[i]=r;
c[i]=k-(r-l);
} else {
a[i]=r;
b[i]=l;
c[i]=(r-l)-k+1;
}
}
for (int i = 0; i<n; i++){
a[m+2*i]=i;
b[m+2*i]=i+1;
c[m+2*i]=-1;
a[m+2*i+1]=i+1;
b[m+2*i+1]=i;
c[m+2*i+1]=0;
}
m+=2*n;
bool changed = true;
bool works = true;
int vals[15001];
vals[0]=0;
for (int i = 1; i<=n; i++){
vals[i]=INF;
}
for (int i = 0; i<=n; i++){
bool changed = false;
for (int i = 0; i<m; i++){
if (vals[b[i]]>vals[a[i]]-c[i]){
vals[b[i]]=vals[a[i]]-c[i];
changed=true;
}
}
if (changed&&i==n){
works=false;
}
//if (!changed){break;}
}
if (!works){
cout<<-1<<'\n';
return;
}
/*for (int i = 0; i<=n; i++){
cout<<vals[i]<<' ';
}cout<<'\n';*/
for (int i = 0; i<n; i++){
cout<<vals[i+1]-vals[i]<<' ';
}cout<<'\n';
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>m;
/*if (n<=18){
subtask1();
} else {*/
relaxedges();
//}
}
컴파일 시 표준 에러 (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... |