fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S chmin(S &a, T b){
  5. if(a>b){
  6. a=b;
  7. }
  8. return a;
  9. }
  10. #define main dummy_main
  11. int main(){
  12. return 0;
  13. }
  14. #undef main
  15. int dist[100][100];
  16. class Solution{
  17. public:
  18. int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold){
  19. int i;
  20. int j;
  21. int k;
  22. int cnt;
  23. int res = -1;
  24. int mn = 1073709056;
  25. for(i=(0);i<(n);i++){
  26. for(j=(0);j<(n);j++){
  27. dist[i][j] = 1073709056;
  28. }
  29. }
  30. for(i=(0);i<(n);i++){
  31. dist[i][i] = 0;
  32. }
  33. for(i=(0);i<(edges.size());i++){
  34. j = edges[i][0];
  35. k = edges[i][1];
  36. dist[j][k] =chmin(dist[k][j], edges[i][2]);
  37. }
  38. for(k=(0);k<(n);k++){
  39. for(i=(0);i<(n);i++){
  40. for(j=(i+1);j<(n);j++){
  41. dist[i][j] =chmin(dist[j][i], dist[i][k] + dist[k][j]);
  42. }
  43. }
  44. }
  45. for(i=(0);i<(n);i++){
  46. cnt = 0;
  47. for(j=(0);j<(n);j++){
  48. if(dist[i][j] <= distanceThreshold){
  49. cnt++;
  50. }
  51. }
  52. if(cnt <= mn){
  53. mn = cnt;
  54. res = i;
  55. }
  56. }
  57. return res;
  58. }
  59. }
  60. ;
  61. // cLay varsion 20200119-1
  62.  
  63. // --- original code ---
  64. // #define main dummy_main
  65. // {}
  66. // #undef main
  67. //
  68. // int dist[100][100];
  69. //
  70. // class Solution {
  71. // public:
  72. // int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {
  73. // int i, j, k, cnt, res = -1, mn = int_inf;
  74. // rep(i,n) rep(j,n) dist[i][j] = int_inf;
  75. // rep(i,n) dist[i][i] = 0;
  76. // rep(i,edges.size()){
  77. // j = edges[i][0];
  78. // k = edges[i][1];
  79. // dist[j][k] = dist[k][j] <?= edges[i][2];
  80. // }
  81. // rep(k,n) rep(i,n) rep(j,i+1,n) dist[i][j] = dist[j][i] <?= dist[i][k] + dist[k][j];
  82. // rep(i,n){
  83. // cnt = 0;
  84. // rep(j,n) if(dist[i][j] <= distanceThreshold) cnt++;
  85. // if(cnt <= mn) mn = cnt, res = i;
  86. // }
  87. // return res;
  88. // }
  89. // };
  90.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty