제출 #1340094

#제출 시각아이디문제언어결과실행 시간메모리
1340094model_codeMinistarstvo (COI24_ministarstvo)C++20
100 / 100
79 ms6360 KiB
#include <iostream>
#include <vector>

using namespace std;

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

    int n;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n));
    vector<int> outdeg(n, 0);
    int best = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
            outdeg[i] += a[i][j];
        }
        if (outdeg[i] > outdeg[best]) {
            best = i;
        }
    }

    if (outdeg[best] == n - 1) {
        cout << -1 << '\n';
        return 0;
    }

    static const int color[2][2] = {
        {1, 2},
        {3, 1},
    };

    cout << 3 << '\n';
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int ans = 0;
            if (a[i][j]) {
                ans = color[a[best][i]][a[best][j]];
            }
            cout << ans << (j + 1 == n ? '\n' : ' ');
        }
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...