fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a,b,c,d,e,f,g,h,i,x,z,v,w,q=0;
  6. cin>>a;string ch;
  7. for(b=0;b<a;b++)
  8. {
  9. cin>>c>>d;
  10. cin>>ch;
  11. vector < pair < char, int > > ch3[c+1];w=1;q=0;
  12. for(v=0;v<c;v++)
  13. {
  14. if(v+1<=c-1 && ch[v]==ch[v+1])
  15. {w++;}
  16. else{
  17. ch3[q].push_back( make_pair(ch[v],w));
  18. w=1;q++;
  19. }
  20. }
  21. if(w>1){ch3[q].push_back( make_pair(ch[v],w));
  22. w=0;q++;}else{}
  23. //vector< pair<char,int> > ::iterator it;
  24.  
  25. //for(it=ch3.begin();it!=ch3.end();it++)
  26. for(i=0;i<q;i++)
  27. {
  28. cout<<ch3[i].first<<" "<<ch3[i].second<<"\n";
  29. }
  30. }}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:28:26: error: ‘class std::vector<std::pair<char, int> >’ has no member named ‘first’
             cout<<ch3[i].first<<" "<<ch3[i].second<<"\n";
                          ^~~~~
prog.cpp:28:45: error: ‘class std::vector<std::pair<char, int> >’ has no member named ‘second’; did you mean ‘cend’?
             cout<<ch3[i].first<<" "<<ch3[i].second<<"\n";
                                             ^~~~~~
stdout
Standard output is empty