Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. int GLOBAL_CNT = 0;
  5. int main(){
  6.     string s;
  7.     bool f = false;
  8.     bool add = false;
  9.     int cnt = 0;
  10.     vector<string> ans;
  11.     vector<string> tmp;
  12.     while(getline(cin, s)){
  13.         //if (s[0] == '.') break;
  14.         if (f){
  15.             if (s == "<tr>") {
  16.                 if (add && !tmp.empty()){
  17.                     string tmp2;
  18.                     bool fl = false;
  19.                     for (int i = 0; i < tmp[1].size()-1; ++i){
  20.                         if (tmp[1][i] == '>'){
  21.                             tmp2 += tmp[1][i];
  22.                             tmp2 += to_string(GLOBAL_CNT);
  23.                             fl = true;
  24.                         }
  25.                         if (tmp[1][i] == '<') fl = false;
  26.                         if (!fl)
  27.                             tmp2 += tmp[1][i];
  28.                     }
  29.                     tmp2 += '>';
  30.                     tmp[1] = tmp2;
  31.                     for (int i = 0; i < tmp.size(); ++i){
  32.                         ans.push_back(tmp[i]);
  33.                     }
  34.                 }
  35.                 cnt = 0;
  36.                 tmp.clear();
  37.                 tmp.push_back(s);
  38.                 add = false;
  39.             }
  40.             else {
  41.                 cnt++;
  42.                 if (cnt == 2 && s.substr(s.find(','), 4) == ", 10") {
  43.                     add = true; GLOBAL_CNT++;
  44.                 }
  45.                 tmp.push_back(s);
  46.             }
  47.         }
  48.         if (!f) ans.push_back(s);
  49.         if (s == "<tbody>") f = true;
  50.         if (s == "</tbody>") {
  51.             f = false;
  52.             ans.push_back(s);
  53.         }
  54.     }
  55.     for (int i = 0; i < ans.size(); ++i){
  56.         cout << ans[i];
  57.         if (i != ans.size()-1) cout << '\n';
  58.     }
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement