| Task: | Sukat |
| Sender: | a256 |
| Submission time: | 2024-01-20 13:28:03 +0200 |
| Language: | C++ (C++20) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:18:19: error: 'class std::set<std::pair<int, int> >' has no member named 'push_back'
18 | m.push_back({it->S,jt->S});
| ^~~~~~~~~
input/code.cpp:3:11: error: decrement of member 'std::pair<int, int>::first' in read-only object
3 | #define F first
| ^
input/code.cpp:19:21: note: in expansion of macro 'F'
19 | it->F--;
| ^
input/code.cpp:3:11: error: decrement of member 'std::pair<int, int>::first' in read-only object
3 | #define F first
| ^
input/code.cpp:20:21: note: in expansion of macro 'F'
20 | jt->F--;
| ^
input/code.cpp:23:35: error: no matching function for call to 'std::set<std::pair<int, int> >::erase(std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<int, int> > >&)'
23 | kt=m.erase(kt);
|...Code
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
string s;
int n,k,c[26];
vector<pair<int,int>> v;
set<pair<int,int>> m;
int main(){
cin>>s;
n=s.size();
for(int e:s) ++c[e-'A'];
for(int i=0;i<26;++i) m.insert({c[i],i});
while(m.size()>1){
auto it=m.rbegin();
auto jt=it; jt++;
m.push_back({it->S,jt->S});
it->F--;
jt->F--;
auto kt=m.rbegin();
while(m.size()>1&&kt->F==0){
kt=m.erase(kt);
}
}
cout<<v.size()<<'\n';
for(auto p:v){
cout<<(char)p.F<<(char)p.S<<'\n';
}
}
