Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: chillxvtkz
Problemset: อะนาแกรม 2
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 23:00:53
#include <bits/stdc++.h>
#define ll long long
#define ct cout << ' '
#define el cout << endl;
using namespace std;
const int mx = 1e9;
const int mn = -1e9;
int x[300],y[300],sum;
string s,v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> s >> v;
for (int i = 0; i < s.size(); i++)
{
if(s[i]=='A') x['a'] = x['a']+1;
else if(s[i]=='B') x['b'] = x['b']+1;
else if(s[i]=='C') x['c'] = x['c']+1;
else if(s[i]=='D') x['d'] = x['d']+1;
else if(s[i]=='E') x['e'] = x['e']+1;
else if(s[i]=='F') x['f'] = x['f']+1;
else if(s[i]=='G') x['g'] = x['g']+1;
else if(s[i]=='H') x['h'] = x['h']+1;
}
cout << x['a'] << " " << x['b'] << ' ' << x['c'] << ' ' << x['d'] << ' ' << x['e'] << ' ' << x['f'] << ' ' << x['g'] << ' ' << x['h'];el;
for (int i = 0; i < v.size(); i++)
{
if(v[i]=='A') y['a'] = y['a']+1;
else if(v[i]=='B') y['b'] = y['b']+1;
else if(v[i]=='C') y['c'] = y['c']+1;
else if(v[i]=='D') y['d'] = y['d']+1;
else if(v[i]=='E') y['e'] = y['e']+1;
else if(v[i]=='F') y['f'] = y['f']+1;
else if(v[i]=='G') y['g'] = y['g']+1;
else if(v[i]=='H') y['h'] = y['h']+1;
}
cout << y['a'] << " " << y['b'] << ' ' << y['c'] << ' ' << y['d'] << ' ' << y['e'] << ' ' << y['f'] << ' ' << y['g'] << ' ' << y['h'];el;
for (int i = 0; i < 8; i++)
{
cout << abs(x['a'+i]-y['a'+i]) << " ";
sum = sum+abs(x['a'+i]-y['a'+i]);
/* code */
}
el;
if(sum<=3) cout << "anagram";
else cout << "no";
return 0;
}