# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1203 | gs12117 | 탐사 (KOI13_probe) | C++98 | 2 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>
int a[1010][3];
int edge[162][3];
int len[42];
int uft[42][2];
int en;
int n,m;
int f(int x){
if(uft[x][0]==x)return x;
f(uft[x][0]);
uft[x][1]+=uft[uft[x][0]][1];
uft[x][0]=uft[uft[x][0]][0];
return uft[x][0];
}
int main(){
int i,j,k,l,t;
scanf("%d%d",&m,&n);
for(i=0;i<=m;i++){
uft[i][0]=i;
}
for(i=0;i<n;i++){
scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
a[i][0]--;
if(f(a[i][0])==f(a[i][1])){
if(uft[a[i][1]][1]!=uft[a[i][0]][1]+a[i][2]){
printf("NONE");
return 0;
}
}
else{
t=f(a[i][1]);
uft[t][1]=a[i][2]-uft[a[i][1]][1];
uft[t][0]=a[i][0];
edge[en][0]=a[i][0];
edge[en][1]=a[i][1];
edge[en][2]=a[i][2];
en++;
edge[en][0]=a[i][1];
edge[en][1]=a[i][0];
edge[en][2]=-a[i][2];
en++;
}
}
for(i=0;i<m;i++){
edge[en][0]=i;
edge[en][1]=i+1;
edge[en][2]=1;
en++;
edge[en][0]=i+1;
edge[en][1]=i;
edge[en][2]=0;
en++;
}
for(i=1;i<=m;i++){
len[i]=10000000;
}
for(i=0;i<m+7;i++){
t=0;
for(j=0;j<en;j++){
if(len[edge[j][1]]>len[edge[j][0]]+edge[j][2]){
len[edge[j][1]]=len[edge[j][0]]+edge[j][2];
t++;
}
}
if(t==0)break;
}
if(i==m+7){
printf("NONE");
}
else{
for(i=0;i<m;i++){
if(len[i]==len[i+1])printf("-");
else printf("#");
}
}
}
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... |