fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S min_L(S a,T b){
  5. return a<=b?a:b;
  6. }
  7. #define main dummy_main
  8. int main(){
  9. return 0;
  10. }
  11. #undef main
  12. int user;
  13. map<string,int> id;
  14. vector<int> tweet[10000];
  15. int sorted[10000];
  16. class TweetCounts{
  17. public:
  18. TweetCounts(){
  19. user = 0;
  20. id.clear();
  21. }
  22. int getID(string name){
  23. if(!id.count(name)){
  24. tweet[user].clear();
  25. sorted[user] = 1;
  26. id[name] = user++;
  27. }
  28. return id[name];
  29. }
  30. void recordTweet(string name, int tm){
  31. int id = getID(name);
  32. tweet[id].push_back(tm);
  33. sorted[id] = 0;
  34. }
  35. vector<int> getTweetCountsPerFrequency(string freq, string name, int st, int et){
  36. int id = getID(name);
  37. int i;
  38. int n;
  39. int delta;
  40. vector<int> res;
  41. et++;
  42. if(sorted[id]==0){
  43. sorted[id] = 1;
  44. sort(tweet[id].begin(), tweet[id].end());
  45. }
  46. if(freq == "minute"){
  47. delta = 60;
  48. }
  49. if(freq == "hour"){
  50. delta = 60*60;
  51. }
  52. if(freq == "day"){
  53. delta = 60*60*24;
  54. }
  55. i = lower_bound(tweet[id].begin(), tweet[id].end(), st) - tweet[id].begin();
  56. while(st < et){
  57. n = 0;
  58. st =min_L(st+delta, et);
  59. while(i < tweet[id].size() && tweet[id][i] < st){
  60. i++;
  61. n++;
  62. }
  63. res.push_back(n);
  64. }
  65. return res;
  66. }
  67. }
  68. ;
  69. // cLay varsion 20200214-1
  70.  
  71. // --- original code ---
  72. // #define main dummy_main
  73. // {}
  74. // #undef main
  75. //
  76. // int user;
  77. // map<string,int> id;
  78. // vector<int> tweet[10000];
  79. // int sorted[10000];
  80. //
  81. // class TweetCounts {
  82. // public:
  83. // TweetCounts() {
  84. // user = 0;
  85. // id.clear();
  86. // }
  87. //
  88. // int getID(string name){
  89. // if(!id.count(name)){
  90. // tweet[user].clear();
  91. // sorted[user] = 1;
  92. // id[name] = user++;
  93. // }
  94. // return id[name];
  95. // }
  96. //
  97. // void recordTweet(string name, int tm) {
  98. // int id = getID(name);
  99. // tweet[id].push_back(tm);
  100. // sorted[id] = 0;
  101. // }
  102. //
  103. // vector<int> getTweetCountsPerFrequency(string freq, string name, int st, int et) {
  104. // int id = getID(name);
  105. // int i, n, delta;
  106. // vector<int> res;
  107. // et++;
  108. // if(sorted[id]==0){
  109. // sorted[id] = 1;
  110. // sort(tweet[id].begin(), tweet[id].end());
  111. // }
  112. // if(freq == "minute") delta = 60;
  113. // if(freq == "hour") delta = 60*60;
  114. // if(freq == "day") delta = 60*60*24;
  115. //
  116. // i = lower_bound(tweet[id].begin(), tweet[id].end(), st) - tweet[id].begin();
  117. // while(st < et){
  118. // n = 0;
  119. // st = min(st+delta, et);
  120. // while(i < tweet[id].size() && tweet[id][i] < st) i++, n++;
  121. // res.push_back(n);
  122. // }
  123. //
  124. // return res;
  125. // }
  126. // };
  127.  
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