fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. using ll=long long;
  4. using pi=pair<int,int>;
  5. using vi=vector<int>;
  6. #define mp make_pair
  7. #define eb emplace_back
  8. #define x first
  9. #define y second
  10. #define sz(x)int((x).size())
  11. #define all(x)(x).begin(),(x).end()
  12. #define rep(i,a,b)for(int i=(a);i<(b);i++)
  13. #define per(i,a,b)for(int i=(b)-1;i>=(a);i--)
  14. bool ckmin(auto&a,auto b){return b<a?a=b,1:0;}
  15. bool ckmax(auto&a,auto b){return b>a?a=b,1:0;}
  16.  
  17. mutex dbg_mtx;
  18. #ifdef LOCAL
  19. auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.x<<", "<<p.y<<")";}
  20. auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto&e:x)o<<","+!i++<<e;return o<<"}";}
  21. #define debug(X...)cerr<<"["#X"]: ",[](auto...$){lock_guard<mutex> lock(dbg_mtx); ((cerr<<$<<"; "),...)<<endl;}(X);
  22. #else
  23. #define debug(...){}
  24. #endif
  25.  
  26. int cases_completed = 0;
  27. int num_cases;
  28. atomic_int nxt_case;
  29.  
  30. struct solution {
  31. // == TEMPLATE START ==
  32. stringstream out;
  33. int case_id;
  34.  
  35. explicit solution(int _case_id) : case_id(_case_id) {}
  36.  
  37. void on_finish() {
  38. const lock_guard<mutex> lock(dbg_mtx);
  39. cases_completed++;
  40. float percent = (100.0 * cases_completed) / num_cases;
  41. cerr << fixed << setprecision(1);
  42. cerr << "Case #" << case_id + 1 << " completed, " << cases_completed << " / " << num_cases << " (" << percent << "%)" << endl;
  43. }
  44.  
  45. void write() {
  46. cout << "Case #" << case_id + 1 << ": " << out.str();
  47. }
  48.  
  49. // == TEMPLATE END ==
  50. // == VARIABLES START ==
  51.  
  52.  
  53. // == VARIABLES END ==
  54. // == METHODS START ==
  55.  
  56. void read() {
  57.  
  58. }
  59.  
  60. void solve() {
  61.  
  62. }
  63.  
  64. // == METHODS END ==
  65.  
  66. };
  67.  
  68. constexpr int NUM_PROCSESORS = 14;
  69.  
  70. vector<solution> solutions;
  71. vector<thread> processors;
  72.  
  73. void run() {
  74. while (true) {
  75. int i = nxt_case.fetch_add(1);
  76. if (i >= num_cases) {
  77. return;
  78. }
  79.  
  80. solutions[i].solve();
  81. solutions[i].on_finish();
  82. }
  83. }
  84.  
  85. signed main() {
  86. cin.tie(0)->sync_with_stdio(0);
  87.  
  88. cin >> num_cases;
  89. solutions.reserve(num_cases);
  90.  
  91. rep(i, 0, num_cases) {
  92. solutions.eb(i);
  93. solutions.back().read();
  94. }
  95.  
  96. cerr << "Input read, starting processors" << endl;
  97.  
  98. rep(i, 0, NUM_PROCSESORS) {
  99. processors.emplace_back(run);
  100. }
  101.  
  102. for (auto &processor : processors) {
  103. processor.join();
  104. }
  105.  
  106. cerr << "Finished processing, writing output" << endl;
  107.  
  108. for (auto &solution : solutions) {
  109. solution.write();
  110. }
  111.  
  112. return 0;
  113. }
  114.  
  115.  
Success #stdin #stdout #stderr 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Input read, starting processors
Finished processing, writing output