답안 #16230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16230 2015-08-18T10:23:48 Z eaststar 탐사 (KOI13_probe) C++14
19 / 19
3 ms 376 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
struct data{
    int s,e,w;
}a[1010];
int ans[41];
int main(){
    int i,j,k,n;
    scanf("%d%d",&k,&n);
    for(i=1;i<=n;++i){
        scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].w);
        --a[i].s;
    }
    for(i=1;i<=k;++i)ans[i]=i;
    for(i=1;i<=k;++i){
        for(j=0;j<k;++j){
            ans[j+1]=min(ans[j+1],ans[j]+1);
            ans[j]=min(ans[j],ans[j+1]);
        }
        for(j=1;j<=n;++j){
            ans[a[j].e]=min(ans[a[j].e],ans[a[j].s]+a[j].w);
            ans[a[j].s]=min(ans[a[j].s],ans[a[j].e]-a[j].w);
        }
    }
    for(i=1;i<=k;++i)if(ans[i]<0||ans[i]-ans[i-1]>1)break;
    if(i>k)for(i=1;i<=k;++i)printf("%c",ans[i]-ans[i-1]?'#':'-');
    else puts("NONE");
    return 0;
}

Compilation message

probe.cpp: In function 'int main()':
probe.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&k,&n);
     ~~~~~^~~~~~~~~~~~~~
probe.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].w);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 228 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 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 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct