Submission #13123

#TimeUsernameProblemLanguageResultExecution timeMemory
13123gs14004탐사 (KOI13_probe)C++14
19 / 19
7 ms428 KiB
#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)

probe.cpp: In function 'int main()':
probe.cpp:12: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:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&x,&y,&z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...