Skip to content

Commit

Permalink
Add 24494.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jul 16, 2024
1 parent 653d83b commit 5e372dc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 24xxx/24494.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

void solve(void) {
vector<string> a(3), b(3);
for (int i=0; i<3; i++) cin >> a[i];
for (int i=0; i<3; i++) cin >> b[i];

unordered_map<char, int> cntA, cntB;
for (int i=0; i<3; i++) for (int j=0; j<3; j++) {
cntA[a[i][j]]++; cntB[b[i][j]]++;
}

int c = 0, d = 0;
for (int i=0; i<3; i++) for (int j=0; j<3; j++) c += a[i][j] == b[i][j];
for (char ch='A'; ch<='Z'; ch++) d += min(cntA[ch], cntB[ch]);

cout << c << "\n" << d - c;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit 5e372dc

Please sign in to comment.