123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "recorder.h"
- #include "utils.h"
- #include <fstream>
- #include <ostream>
- #include <istream>
- #include <string>
- using namespace std;
- struct ExampleTask
- {
- string s;
- long long score()
- {
- auto answer = 0;
- for (auto x : s)
- {
- answer += x == 'a';
- }
- return answer;
- }
- void save(ostream &output, ostream &info)
- {
- output << s << endl;
- info << "string: " << s << endl;
- }
- void load(istream &output, istream &info)
- {
- output >> s;
- }
- };
- int main()
- {
- Recorder<ExampleTask> rec("a");
- ExampleTask task;
- rec.load(task);
- task.s = "aafasfasfasfasfdasdf";
- rec.submit(task);
- long long pig = 0;
- // This function will be called multiple times for 10 milliseconds.
- // It will be checked every 2_000_000 iterations.
- run_while([&]() {
- pig++;
- },
- 2000000, 10);
- cout << pig << endl;
- return 0;
- }
|