# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429517 | 2021-06-16T05:05:57 Z | 조영욱(#7653) | Brackets (CPSPC17_brackets) | C++17 | 700 ms | 1100 KB |
#include <bits/stdc++.h> using namespace std; char str[8]={'(','{','[','<','>',']','}',')'}; bool vis[200][200]; long long dist[200][200]; long long dist2[200][200]; int arr[200][200]; int n,m; const long long INF=2e18; int main(void) { int s,t; scanf("%d %d %d %d",&n,&m,&s,&t); s--; t--; memset(arr,-1,sizeof(arr)); for(int i=0;i<m;i++) { int u,v; char c; scanf("%d %d %c",&u,&v,&c); u--; v--; int val=-1; for(int j=0;j<8;j++) { if (str[j]==c){ val=j; break; } } arr[u][v]=val; } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if (i==j) { dist[i][j]=0; } else { dist[i][j]=INF; } } } for(int ind=0;ind<n*n;ind++) { int xpos=0; int ypos=0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { dist2[i][j]=dist[i][j]; if (!vis[i][j]) { if (vis[xpos][ypos]||dist[i][j]<dist[xpos][ypos]) { xpos=i; ypos=j; } } } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if (arr[i][xpos]+arr[ypos][j]==7) { dist[i][j]=min(dist[i][j],dist2[xpos][ypos]+2); } } } for(int i=0;i<n;i++) { dist[xpos][i]=min(dist[xpos][i],dist2[xpos][ypos]+dist2[ypos][i]); dist[i][ypos]=min(dist[i][ypos],dist2[i][xpos]+dist2[xpos][ypos]); } vis[xpos][ypos]=true; } printf("%lld\n",dist[s][t]>INF/2?-1:dist[s][t]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1099 ms | 1100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |