提出 #17532729


ソースコード 拡げる

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ll128 __uint128_t
#define ld long double
#define pll pair <ll, ll>

#define vll vector <ll>
#define vld vector<ld>
#define vpll vector<pll>

#define vvll vector <vll>

#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
#define per(i, a, b) for(ll i = (ll)a - 1; i >= (ll)b; --i)

#define endl "\n"
#define pb push_back
#define pf push_front

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define sorta(v) sort(all(v))
#define sortd(v) sort(rall(v))

#define debug if (1)
#define log(val) debug {cout << "\n" << #val << ": " << val << "\n";}

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(name) freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

#define mod (ll)(1e9 + 7)
#define inf (mod * mod)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

ostream & operator << (ostream & out, vll & a) {
    for(auto i : a) out << i << " ";
    return out;
}

istream & operator >> (istream & in, vll & a) {
    for(auto &i : a) in >> i;
    return in;
}

const ll N = 505;
char a[N][N];
ll cnt[N];
ll cntFull = 0;

int main() {
    ll n;
    cin >> n;

    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                cnt[i]++;
            }
        }
    }
    ll uu = 0;
    rep(j, 0, n) {
        ll oo = 0;
        rep(i, 0, n) {
            oo |= (a[i][j] == '.');
            uu |= (a[i][j] == '#');
        }
        if (!oo) cntFull++;
    }
    if (!uu) return cout << -1, 0;
    ll ans = 1e9;
    rep(j, 0, n) {
        rep(i, 0, n) {
            if (a[i][j] == '#') {
                ans = min(ans, n - cnt[j]);
            }
        }
        ans = min(ans, n - cnt[j] + 1);
    }

    if (ans == 1e9) return cout << -1, 0;

    cout << ans + n - cntFull << endl;



    return 0;
}

提出情報

提出日時
問題 B - Row to Column
ユーザ BOGDAN_
言語 C++ (GCC 9.2.1)
得点 1300
コード長 2191 Byte
結果 AC
実行時間 23 ms
メモリ 3912 KiB

ジャッジ結果

セット名 Sample Subtask All
得点 / 配点 0 / 0 300 / 300 1000 / 1000
結果
AC × 5
AC × 20
AC × 43
セット名 テストケース
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
Subtask 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt
ケース名 結果 実行時間 メモリ
0_00.txt AC 7 ms 3604 KiB
0_01.txt AC 2 ms 3604 KiB
0_02.txt AC 2 ms 3576 KiB
0_03.txt AC 2 ms 3460 KiB
0_04.txt AC 2 ms 3444 KiB
1_00.txt AC 3 ms 3600 KiB
1_01.txt AC 2 ms 3412 KiB
1_02.txt AC 2 ms 3596 KiB
1_03.txt AC 2 ms 3440 KiB
1_04.txt AC 2 ms 3556 KiB
1_05.txt AC 2 ms 3596 KiB
1_06.txt AC 5 ms 3568 KiB
1_07.txt AC 1 ms 3592 KiB
1_08.txt AC 2 ms 3448 KiB
1_09.txt AC 2 ms 3592 KiB
1_10.txt AC 2 ms 3412 KiB
1_11.txt AC 2 ms 3560 KiB
1_12.txt AC 2 ms 3604 KiB
1_13.txt AC 2 ms 3576 KiB
1_14.txt AC 2 ms 3580 KiB
2_00.txt AC 20 ms 3840 KiB
2_01.txt AC 17 ms 3644 KiB
2_02.txt AC 16 ms 3696 KiB
2_03.txt AC 18 ms 3848 KiB
2_04.txt AC 17 ms 3644 KiB
2_05.txt AC 16 ms 3824 KiB
2_06.txt AC 19 ms 3696 KiB
2_07.txt AC 14 ms 3656 KiB
2_08.txt AC 20 ms 3844 KiB
2_09.txt AC 23 ms 3872 KiB
2_10.txt AC 19 ms 3680 KiB
2_11.txt AC 18 ms 3876 KiB
2_12.txt AC 16 ms 3684 KiB
2_13.txt AC 15 ms 3832 KiB
2_14.txt AC 18 ms 3636 KiB
2_15.txt AC 13 ms 3620 KiB
2_16.txt AC 14 ms 3756 KiB
2_17.txt AC 17 ms 3616 KiB
2_18.txt AC 13 ms 3600 KiB
2_19.txt AC 13 ms 3912 KiB
2_20.txt AC 15 ms 3836 KiB
2_21.txt AC 13 ms 3636 KiB
2_22.txt AC 23 ms 3684 KiB