# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13122 | gs14004 | 탐사 (KOI13_probe) | C++14 | 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 <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int adj[50][50], k, n;
int hard[50];
int main(){
memset(adj,0x3f,sizeof(adj));
memset(hard,-1,sizeof(hard));
scanf("%d %d",&k,&n);
for (int i=1; i<=k; i++) {
adj[i][i+1] = 1;
adj[i+1][i] = 0;
adj[i][i] = 0;
}
for (int i=0; i<n; i++) {
int x,y,z;
scanf("%d %d %d",&x,&y,&z);
if(x != y && adj[x][y+1] < 1e9 && adj[x][y+1] != z){
puts("NONE");
return 0;
}
if(x == y){
if(hard[x] != -1 && hard[x] != z){
puts("NONE");
return 0;
}
hard[x] = z;
}
adj[x][y+1] = z;
adj[y+1][x] = -z;
}
for (int i=1; i<=k+1; i++) {
for (int j=1; j<=k+1; j++) {
for (int l=1; l<=k+1; l++) {
adj[j][l] = min(adj[j][l],adj[j][i] + adj[i][l]);
}
}
}
for (int i=1; i<=k+1; i++) {
if(adj[i][i] < 0){
puts("NONE");
return 0;
}
}
for (int i=1; i<=k; i++) {
if(adj[i][i+1] > 1 || adj[i][i+1] < 0 || (~hard[i] && adj[i][i+1] != hard[i])){
puts("NONE");
return 0;
}
}
for (int i=1; i<=k; i++) {
if(adj[1][i+1] - adj[1][i]) putchar('#');
else putchar('-');
}
}
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... |