# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3141 | club4208 | 탐사 (KOI13_probe) | C++98 | 3 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define INF 10000001
int a[1001],b[1001],d[1001],c[1001],n,k,i,j;
int min(int a, int b){
if(a<b) return a;
return b;
}
int main(){
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
scanf("%d %d", &n, &k);
for(i=1;i<=n;i++) d[i]=INF;
d[0]=0;
for(i=1;i<=k;i++){
scanf("%d %d %d", &a[i], &b[i], &c[i]);
a[i]--;
}
for(i=1;i<=n+1;i++){
for(j=0;j<n;j++){
if(d[j]!=INF) d[j+1]=min(d[j+1], d[j]+1);
}
for(j=0;j<n;j++){
if(d[j+1]!=INF) d[j]=min(d[j], d[j+1]);
}
for(j=1;j<=k;j++){
if(d[a[j]]!=INF) d[b[j]]=min(d[b[j]], d[a[j]]+c[j]);
}
for(j=1;j<=k;j++){
if(d[b[j]]!=INF) d[a[j]]=min(d[a[j]], d[b[j]]-c[j]);
}
}
if(d[1]<0) printf("NONE");
else{
for(i=1;i<=n;i++){
if(d[i]-d[i-1]==1) printf("#");
else printf("-");
}
}
return 0;
}
Compilation message (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |