| Task: | Sukat |
| Sender: | maweiyin24562 |
| Submission time: | 2024-01-20 13:44:57 +0200 |
| Language: | C++ (C++11) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp:22:6: error: expected initializer before 'MaxList'
22 | node MaxList(){
| ^~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
input/code.cpp:39:5: error: 'node' was not declared in this scope; did you mean 'Node'?
39 | node ml=MaxList();
| ^~~~
| Node
input/code.cpp:40:11: error: 'ml' was not declared in this scope; did you mean 'll'?
40 | while(ml.cnt){
| ^~
| ll
input/code.cpp:42:13: error: expected ';' before 'sl'
42 | node sl=MaxList();
| ^~~
| ;
input/code.cpp:43:12: error: 'sl' was not declared in this scope; did you mean 's'?
43 | if(sl.cnt==0)break;
| ^...Code
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
string s;
int idx[30];
int ans;
string anslist[200009];
struct Node{
int cnt,id;
}
node MaxList(){
node ret;
ret.id=0;
ret.cnt=0;
for(int i=1;i<=26;i++){
if(idx[i]>ret.cnt);
ret.cnt=idx[i];
ret.id=i;
}
return ret;
}
int main(){
cin>>s;
for(int i=0;i<s.size();i++){
idx[s[i]-'A'+1]++;
}
node ml=MaxList();
while(ml.cnt){
idx[ml.id]=0;
node sl=MaxList();
if(sl.cnt==0)break;
ml.cnt=ml.cnt-sl.cnt;
idx[ml.id]=ml.cnt;
for(int i=1;i<=sl.cnt;i++){
ans++;
anslist[ans]=(char)(ml.id-1+'A')+(char)(sl.id-1+'A');
}
idx[sl.id]=0;
ml=MaxList();
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++){
cout<<anslist[i]<<endl;
}
return 0;
}