Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef string str;
- //typedef __int128 ultraint;
- #define endl "\n"
- #define sqrt sqrtl
- //#define pow fast_pow
- const ll inf = (ll)1e18 + 7;
- ld eps = 1e-6;
- ld Pi = 3.14159265358979323846;
- signed main() {
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- ll t = 1;
- //cin >> t
- while (t--) {
- ll u, d, m, i, j, y, z;
- cin >> u >> d >> m;
- set <char> x;
- pair <ll, ll> ans = { 0,1 }, elem;
- char h;
- string s;
- cin >> s;
- for (i = 0; i < s.size(); i++) {
- x.insert(s[i]);
- }
- vector <vector <ll> > a(u + 1, vector <ll>(d + 1));
- vector <vector <ll> > c(u + 1, vector <ll>(d + 1));
- for (i = 1; i <= u; i++) {
- for (j = 1; j <= d; j++) {
- cin >> h;
- if (x.count(h)) {
- a[i][j] = 1;
- }
- }
- }
- for (j = 1; j <= d; j++) {
- c[1][j] = c[1][j - 1] + a[1][j];
- }
- for (i = 1; i <= u; i++) {
- c[i][1] = c[i - 1][1] + a[i][1];
- }
- for (i = 2; i <= u; i++) {
- for (j = 2; j <= d; j++) {
- c[i][j] = c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1] + a[i][j];
- }
- }
- for (i = 1; i <= u; i++) {
- for (j = 1; j <= d; j++) {
- for (y = i + m - 1; y <= u; y++) {
- for (z = j + m - 1; z <= d; z++) {
- elem.first = c[y][z] - c[i - 1][z] - c[y][j - 1] + c[i - 1][j - 1];
- elem.second = (y - i + 1) * (z - j + 1);
- if (ans.first * elem.second - ans.second * elem.first < 0) {
- ans = elem;
- }
- else if (ans.first * elem.second - ans.second * elem.first == 0 && elem.second > ans.second) {
- ans = elem;
- }
- }
- }
- }
- }
- cout << ans.first << "/" << ans.second << endl;
- }
- }
- //痛みを受け入れる。 痛みを知っています。 痛みを感じる。 痛みを参照してください。 真の痛みを知らなければ、真の世界を理解することは不可能です。 今、あなたは痛みを知るでしょう。 神の罰!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement