example.cpp 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "recorder.h"
  2. #include "utils.h"
  3. #include <fstream>
  4. #include <ostream>
  5. #include <istream>
  6. #include <string>
  7. using namespace std;
  8. struct ExampleTask
  9. {
  10. string s;
  11. long long score()
  12. {
  13. auto answer = 0;
  14. for (auto x : s)
  15. {
  16. answer += x == 'a';
  17. }
  18. return answer;
  19. }
  20. void save(ostream &output, ostream &info)
  21. {
  22. output << s << endl;
  23. info << "string: " << s << endl;
  24. }
  25. void load(istream &output, istream &info)
  26. {
  27. output >> s;
  28. }
  29. };
  30. int main()
  31. {
  32. Recorder<ExampleTask> rec("a");
  33. ExampleTask task;
  34. rec.load(task);
  35. task.s = "aafasfasfasfasfdasdf";
  36. rec.submit(task);
  37. long long pig = 0;
  38. // This function will be called multiple times for 10 milliseconds.
  39. // It will be checked every 2_000_000 iterations.
  40. run_while([&]() {
  41. pig++;
  42. },
  43. 2000000, 10);
  44. cout << pig << endl;
  45. return 0;
  46. }