提出 #74230258


ソースコード 拡げる

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<long long> vll;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#define endl '\n'
ll mod = 1e9+7 ;
int p1 = 31 , p2 = 91 ;
ll mod1= 1e9+7 , mod2 = 1e9+9 ;

void solve() {
    int n , m ; cin >> n >> m ;
    vector<string> v(n) ;
    for(int i = 0 ; i < n ;++i) cin >> v[i] ;
    int ans = n ;
    for(int i = 1 ; i < (1<<n) ; ++i) {
        map<int,bool> mp ;
        int cnt =0 ;
        for(int j = 0  ; j < n ;++j) {
            if(i&(1<<j)){
                cnt ++ ;
                for(int ii = 0 ; ii < m ;++ii) {
                    if(v[j][ii] =='o') mp[ii] =1 ;
                }
            }
        }
        bool test = 1 ;
        for(int ii = 0 ; ii < m ; ++ii) if(mp[ii] == 0) test = 0 ;
        if(test) ans = min(ans , cnt );
    }
    cout << ans << endl ;
 }





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

提出情報

提出日時
問題 F - Popcorn
ユーザ Code_Pro
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1157 Byte
結果 AC
実行時間 2 ms
メモリ 3688 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 28
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3500 KiB
00_sample_01.txt AC 1 ms 3456 KiB
00_sample_02.txt AC 1 ms 3588 KiB
01_random_00.txt AC 1 ms 3452 KiB
01_random_01.txt AC 1 ms 3680 KiB
01_random_02.txt AC 1 ms 3672 KiB
01_random_03.txt AC 1 ms 3680 KiB
01_random_04.txt AC 1 ms 3596 KiB
01_random_05.txt AC 1 ms 3512 KiB
01_random_06.txt AC 2 ms 3680 KiB
01_random_07.txt AC 1 ms 3456 KiB
01_random_08.txt AC 1 ms 3596 KiB
01_random_09.txt AC 1 ms 3596 KiB
01_random_10.txt AC 1 ms 3688 KiB
01_random_11.txt AC 1 ms 3452 KiB
01_random_12.txt AC 1 ms 3512 KiB
01_random_13.txt AC 1 ms 3552 KiB
01_random_14.txt AC 1 ms 3672 KiB
01_random_15.txt AC 1 ms 3512 KiB
01_random_16.txt AC 2 ms 3680 KiB
01_random_17.txt AC 1 ms 3680 KiB
01_random_18.txt AC 1 ms 3680 KiB
01_random_19.txt AC 1 ms 3680 KiB
01_random_20.txt AC 1 ms 3544 KiB
02_handmade_00.txt AC 1 ms 3688 KiB
02_handmade_01.txt AC 1 ms 3588 KiB
02_handmade_02.txt AC 1 ms 3500 KiB
02_handmade_03.txt AC 1 ms 3520 KiB