Submission #4278

# Submission time Handle Problem Language Result Execution time Memory
4278 2013-09-11T07:59:09 Z club4208 탐사 (KOI13_probe) C++
19 / 19
2 ms 384 KB
#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(){ 
    scanf("%d %d", &n, &k); 
    for(i=1;i<=n;i++) d[i]=INF; 
    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]) printf("#"); else printf("-"); }
    return 0; 
}

Compilation message

probe.cpp: In function 'int main()':
probe.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k); 
     ~~~~~^~~~~~~~~~~~~~~~~
probe.cpp:8:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=k;i++) scanf("%d %d %d", &a[i], &b[i], &c[i]), a[i]--; 
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 352 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct