fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define main dummy_main
  4. int main(){
  5. return 0;
  6. }
  7. #undef main
  8. class SnapshotArray{
  9. int cur;
  10. vector<int> t[50000], v[50000];
  11. public:
  12. SnapshotArray(int length){
  13. int i;
  14. cur = 0;
  15. for(i=0;i<(length);i++){
  16. v[i].push_back(0);
  17. }
  18. for(i=0;i<(length);i++){
  19. t[i].push_back(0);
  20. }
  21. }
  22. void set(int index, int val){
  23. if(t[index][t[index].size()-1] == cur){
  24. v[index][v[index].size()-1] = val;
  25. }
  26. else{
  27. v[index].push_back(val);
  28. t[index].push_back(cur);
  29. }
  30. }
  31. int snap(){
  32. return cur++;
  33. }
  34. int get(int index, int snap_id){
  35. int i;
  36. i = upper_bound(t[index].begin(), t[index].end(), snap_id) - t[index].begin();
  37. return v[index][i-1];
  38. }
  39. }
  40. ;
  41. // cLay varsion 20190810-2
  42.  
  43. // --- original code ---
  44. // #define main dummy_main
  45. // {}
  46. // #undef main
  47. //
  48. // class SnapshotArray {
  49. // public:
  50. // vector<int> v[50000], t[50000];
  51. // int cur;
  52. //
  53. // SnapshotArray(int length) {
  54. // int i;
  55. // cur = 0;
  56. // rep(i,length) v[i].push_back(0);
  57. // rep(i,length) t[i].push_back(0);
  58. // }
  59. //
  60. // void set(int index, int val) {
  61. // if(t[index][t[index].size()-1] == cur){
  62. // v[index][v[index].size()-1] = val;
  63. // } else {
  64. // v[index].push_back(val);
  65. // t[index].push_back(cur);
  66. // }
  67. // }
  68. //
  69. // int snap() {
  70. // return cur++;
  71. // }
  72. //
  73. // int get(int index, int snap_id) {
  74. // int i;
  75. // i = upper_bound(t[index].begin(), t[index].end(), snap_id) - t[index].begin();
  76. // return v[index][i-1];
  77. // }
  78. // };
  79.  
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