Submission #12922

# Submission time Handle Problem Language Result Execution time Memory
12922 2015-01-20T11:17:07 Z baneling100 탐사 (KOI13_probe) C++
19 / 19
4 ms 380 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
#define INF 0x7fffffff

using namespace std;

typedef pair <int,int> ppair;
vector <ppair> Edge[41];
int K, N, Dist[41];

int main(void) {

    int i, j, k, l, in1, in2, in3, update;

    scanf("%d %d",&K,&N);
    for(i=1 ; i<=K ; i++) {
        Edge[i-1].push_back(make_pair(i  ,1));
        Edge[i  ].push_back(make_pair(i-1,0));
        Dist[i]=INF;
    }
    for(i=1 ; i<=N ; i++) {
        scanf("%d %d %d",&in1,&in2,&in3);
        in1--;
        Edge[in1].push_back(make_pair(in2,in3 ));
        Edge[in2].push_back(make_pair(in1,-in3));
    }
    for(i=0 ; i<=K ; i++) {
        update=1;
        for(j=0 ; j<=K ; j++) {
            l=Edge[j].size();
            for(k=0 ; k<l ; k++)
                if(Dist[Edge[j][k].first]>Dist[j]+Edge[j][k].second) {
                    Dist[Edge[j][k].first]=Dist[j]+Edge[j][k].second;
                    update=0;
                }
        }
        if(update)
            break;
    }
    if(Dist[0]<0)
        printf("NONE");
    else
        for(i=1 ; i<=K ; i++) {
            if(Dist[i]-Dist[i-1])
                printf("#");
            else
                printf("-");
        }
    return 0;
}

Compilation message

probe.cpp: In function 'int main()':
probe.cpp:16: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:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&in1,&in2,&in3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 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 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 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 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct