# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
12921 | baneling100 | 탐사 (KOI13_probe) | C++98 | 2 ms | 424 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>
#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 (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... |