fork download
  1. #include "message.h"
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <cassert>
  5. #include <sstream>
  6. using namespace std;
  7. #define make(type, x) type x; cin>>x;
  8. #define make2(type, x, y) type x, y; cin>>x>>y;
  9. #define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
  10. #define MP make_pair
  11. template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
  12. template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
  13. template<class T1, class T2>
  14. ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
  15. typedef pair<int, int> PII;
  16. const int N = 1e5 + 5;
  17. const int H = 1e4 + 5;
  18. const int W = 1e2 + 5;
  19. char a[N], b[N];
  20.  
  21. pair<int, int> dp[H][W];
  22. int main() {
  23. make2(int, row, col);
  24. int inst_num = min(NumberOfNodes(), row);
  25. long long start_row = 1 + MyNodeId() * row / inst_num;
  26. long long end_row = ((MyNodeId() + 1) * row) / inst_num;
  27. if (MyNodeId() >= inst_num) {
  28. return 0;
  29. }
  30. for (int i = 1; i <= row; i++) {
  31. cin>>a[i];
  32. }
  33. for (int i = 1; i <= col; i++) {
  34. cin>>b[i];
  35. }
  36.  
  37. int computed_cols = 0;
  38. int cols_in_package = 102;
  39. while (computed_cols < col) {
  40. int my_hei = end_row - start_row + 1;
  41. for (int i = 0; i <= my_hei; i++) {
  42. if (computed_cols == 0) {
  43. dp[i][0] = MP(i + start_row - 1, 0);
  44. } else {
  45. dp[i][0] = dp[i][cols_in_package];
  46. }
  47. }
  48. int inst = MyNodeId();
  49. int new_cols = min(cols_in_package, col - computed_cols);
  50. if (inst > 0) {
  51. Receive(inst - 1);
  52. }
  53. for (int c = 1; c <= new_cols; c++) {
  54. if (inst > 0) {
  55. int fir = GetInt(inst - 1);
  56. int sec = GetInt(inst - 1);
  57. dp[0][c] = MP(fir, sec);
  58. } else {
  59. dp[0][c] = MP(computed_cols + c, 0);
  60. }
  61. for (int r = 1; r <= my_hei; r++) {
  62. int i = r - 1 + start_row;
  63. int j = computed_cols + c;
  64.  
  65. PII left = dp[r][c - 1];
  66. left.first++;
  67. PII right = dp[r - 1][c];
  68. right.first++;
  69. PII diag = dp[r - 1][c - 1];
  70. if (a[i] != b[j]) {
  71. diag.first++;
  72. }
  73. if (a[i] < b[j]) {
  74. diag.second++;
  75. }
  76. dp[r][c] = min(min(left, right), diag);
  77. if (i == row && j == col) {
  78. cout<<dp[r][c].first<<" "<<dp[r][c].second<<endl;
  79. }
  80. }
  81. if (inst < inst_num - 1) {
  82. PutInt(inst + 1, dp[my_hei][c].first);
  83. PutInt(inst + 1, dp[my_hei][c].second);
  84. }
  85. }
  86. computed_cols += new_cols;
  87. if (inst < inst_num - 1) {
  88. Send(inst + 1);
  89. }
  90. }
  91.  
  92.  
  93. return 0;
  94. }
  95.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: message.h: No such file or directory
 #include "message.h"
                     ^
compilation terminated.
stdout
Standard output is empty