1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;


bool isPossible(double T, int L, const vector<vector<bool>>& availability) {
    vector<double> sleepTime(L, 0);
    for (int i = 0; i < L; ++i) {
        int count = 0;
        for (const auto& person : availability) {
            if (!person[i]) ++count;
        }
        if (count == 0) return false;
        sleepTime[i] = count - 1;
    }
    double totalSleep = accumulate(sleepTime.begin(), sleepTime.end(), 0.0);
    return totalSleep >= T * availability.size();
}

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    int n, L;
    cin >> n >> L;

    vector<vector<bool>> availability(n, vector<bool>(L, false));

    for (int i = 0; i < n; ++i) {
        string schedule;
        cin >> schedule;
        for (int j = 0; j < L; ++j) {
            availability[i][j] = (schedule[j] == '.');
        }
    }

    double left = 0, right = L;
    double bestT = -1;

    for (int iter = 0; iter < 100; ++iter) {
        double mid = (left + right) / 2;
        if (isPossible(mid, L, availability)) {
            bestT = mid;
            left = mid;
        } else {
            right = mid;
        }
    }

    if (bestT == -1) {
        cout << "-1" << endl;
    } else {
        int numerator = bestT * L;
        int denominator = L;
        int g = gcd(numerator, denominator);
        cout << (numerator / g) << "/" << (denominator / g) << endl;
    }

    return 0;
}