fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define main dummy_main
  5. int main(){
  6. return 0;
  7. }
  8. #undef main
  9. class UndergroundSystem{
  10. public:
  11. int sn;
  12. map<string,int> sID;
  13. map<int,int> p2s;
  14. map<int,int> p2t;
  15. map<pair<int,int>,double> tm;
  16. map<pair<int,int>,double> tot;
  17. UndergroundSystem(){
  18. sn = 0;
  19. }
  20. int stationID(string stationName){
  21. if(sID.count(stationName)){
  22. return sID[stationName];
  23. }
  24. return sID[stationName] = sn++;
  25. }
  26. void checkIn(int id, string stationName, int t){
  27. p2s[id] = stationID(stationName);
  28. p2t[id] = t;
  29. }
  30. void checkOut(int id, string stationName, int t){
  31. int x = p2s[id];
  32. int y = stationID(stationName);
  33. tm[make_pair(x,y)] += 1;
  34. tot[make_pair(x,y)] += t - p2t[id];
  35. }
  36. double getAverageTime(string startStation, string endStation){
  37. int x = stationID(startStation);
  38. int y = stationID(endStation);
  39. return tot[make_pair(x,y)] / tm[make_pair(x,y)];
  40. }
  41. }
  42. ;
  43. // cLay varsion 20200325-1
  44.  
  45. // --- original code ---
  46. // #define main dummy_main
  47. // {}
  48. // #undef main
  49. //
  50. // class UndergroundSystem {
  51. // public:
  52. // int sn;
  53. // map<string,int> sID;
  54. // map<int,int> p2s, p2t;
  55. // map<pair<int,int>,double> tm, tot;
  56. //
  57. // UndergroundSystem() {
  58. // sn = 0;
  59. // }
  60. //
  61. // int stationID(string stationName){
  62. // if(sID.count(stationName)) return sID[stationName];
  63. // return sID[stationName] = sn++;
  64. // }
  65. //
  66. // void checkIn(int id, string stationName, int t) {
  67. // p2s[id] = stationID(stationName);
  68. // p2t[id] = t;
  69. // }
  70. //
  71. // void checkOut(int id, string stationName, int t) {
  72. // int x = p2s[id];
  73. // int y = stationID(stationName);
  74. // tm[make_pair(x,y)] += 1;
  75. // tot[make_pair(x,y)] += t - p2t[id];
  76. // }
  77. //
  78. // double getAverageTime(string startStation, string endStation) {
  79. // int x = stationID(startStation);
  80. // int y = stationID(endStation);
  81. // return tot[make_pair(x,y)] / tm[make_pair(x,y)];
  82. // }
  83. // };
  84.  
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