Submission #54582376


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//A.order_of_key() *A.find_by_order()
#define endl "\n"
#define int long long
#define ld long double
#define pb push_back
#define rep(i,a,b) for(int i = a; i < b; i++)
#define sz(v) v.size()
#define all(x) x.begin(),x.end()
#define in(v) for(int i = 0; i<v.size(); i++) cin>>v[i];
#define out(v) for(int i = 0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define ret(v) cout<<v<<"\n"; return
#define popcount(num) __builtin_popcount(num)
typedef vector<int> vi;
typedef pair<int,int> pii;
const int INF = 1e18;
const int MOD = 998244353;
const int N = 3e5;
const int LN = 20;

void solve(){
int n, m;
cin >> n >> m;

int dp[n + 1][(1 << m)];
for(int i = 0; i <= n; ++i){
    for(int j = 0; j < (1 << m); ++j){
        dp[i][j] = 1e9;
    }
}
dp[0][0] = 0;

for(int i = 0; i < n; ++i){
    string s;
    cin >> s;
    int string_mask = 0;
    for(int j = 0; j < m; ++j){
        if(s[j] == 'o'){
            string_mask = (string_mask | (1 << j));
        }
    }

    for(int mask = 0; mask < (1 << m); ++mask){
        dp[i + 1][mask] = min(dp[i + 1][mask], dp[i][mask]);
        dp[i + 1][string_mask | mask] = min(dp[i + 1][string_mask | mask], dp[i + 1][mask] + 1);
    }
}

cout<<(dp[n][(1 << m) - 1])<<endl;

}
 
int32_t main() {   
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); 
    int t = 1; 
    // cin>>t;
    for(int i = 1; i<=t; i++){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}
 
 

Submission Info

Submission Time
Task C - Popcorn
User TheDivineAurora
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1773 Byte
Status AC
Exec Time 1 ms
Memory 3692 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 28
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3484 KiB
00_sample_01.txt AC 1 ms 3324 KiB
00_sample_02.txt AC 1 ms 3440 KiB
01_random_00.txt AC 1 ms 3524 KiB
01_random_01.txt AC 1 ms 3528 KiB
01_random_02.txt AC 1 ms 3572 KiB
01_random_03.txt AC 1 ms 3548 KiB
01_random_04.txt AC 1 ms 3536 KiB
01_random_05.txt AC 1 ms 3500 KiB
01_random_06.txt AC 1 ms 3572 KiB
01_random_07.txt AC 1 ms 3488 KiB
01_random_08.txt AC 1 ms 3412 KiB
01_random_09.txt AC 1 ms 3560 KiB
01_random_10.txt AC 1 ms 3544 KiB
01_random_11.txt AC 1 ms 3608 KiB
01_random_12.txt AC 1 ms 3688 KiB
01_random_13.txt AC 1 ms 3552 KiB
01_random_14.txt AC 1 ms 3692 KiB
01_random_15.txt AC 1 ms 3564 KiB
01_random_16.txt AC 1 ms 3616 KiB
01_random_17.txt AC 1 ms 3560 KiB
01_random_18.txt AC 1 ms 3500 KiB
01_random_19.txt AC 1 ms 3504 KiB
01_random_20.txt AC 1 ms 3496 KiB
02_handmade_00.txt AC 1 ms 3552 KiB
02_handmade_01.txt AC 1 ms 3492 KiB
02_handmade_02.txt AC 1 ms 3532 KiB
02_handmade_03.txt AC 1 ms 3456 KiB