Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. for (auto it = m.begin(); it != m.end(); it++)
  2. {
  3.     for (list <int>::iterator it1 = it->second.begin(); it1 != it->second.end(); it1++)
  4.     {
  5.         start[c[*it1] - 'a'].push_back(*it1);
  6.         if ((*it1) != n - 1)
  7.             ending[c[(*it1) + 1] - 'a'].push_back(*it1);
  8.     }
  9.     for (int i = 0; i < 26; i++)
  10.     {
  11.         for (int j = 0; j < start[i].size(); j++)
  12.         {
  13.             vector <int>::iterator it = lower_bound(ending[i].begin(), ending[i].end(), start[i][j]);
  14.             result += (ending[i].end() - it);
  15.         }
  16.         start[i].clear();
  17.         ending[i].clear();
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement