Submission #65437458


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define fir first
#define sec second
#define pb push_back
#define bs basic_string
#define sz(v) (LL)(v).size()
#define cir(x) rep(__tmp, 1, x)
#define rd(x) scanf("%lld", &(x))
#define all(v) (v).begin(), (v).end()
#define erg(i, pre, x) for(LL i = (pre)[x];i;i = a[i].next)
#define rep(i, l, r) for(LL i = (l), _tmp = (r);i <= _tmp;i++)
#define per(i, l, r) for(LL i = (l), _tmp = (r);i >= _tmp;i--)
typedef long long LL;
typedef pair<LL, LL> PII;
const LL INF = 0x3f3f3f3f3f3f3f3f, INF_BIT = 0x3f;

const LL N = 15, M = 110;

LL n, m;
LL a[N];
LL s, x;

bool vis[N][M];

LL cnt[M];
LL ans = INF;
void dfs(LL x, LL can, LL sum){
    if(x > n){
        // printf("%lld %lld\n", can, sum);
        if(can == m) ans = min(ans, sum);
        return;
    }
    rep(i, 0, 2){
        dfs(x + 1, can, sum + i * a[x]);
        rep(j, 1, m) if(vis[x][j]){
            cnt[j]++;
            if(cnt[j] == 2) can++;
        }
    }
    rep(j, 1, m) if(vis[x][j]) cnt[j] -= 3;
}

void solve(){
    rd(n), rd(m);
    rep(i, 1, n) rd(a[i]);
    rep(i, 1, m){
        rd(s);
        cir(s) rd(x), vis[x][i] = true;
    }
    
    dfs(1, 0, 0);
    
    printf("%lld\n", ans);
}

int main(){
    // freopen("1.in", "r", stdin);  //std=
    // freopen("1.out", "w", stdout);
    // freopen("problem.in", "r", stdin);
    // freopen("problem.out", "w", stdout);
    
    solve();
    return 0;
}

Submission Info

Submission Time
Task D - Goin' to the Zoo
User jimmy2025
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1489 Byte
Status AC
Exec Time 16 ms
Memory 3836 KiB

Compile Error

Main.cpp: In function ‘void solve()’:
Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define rd(x) scanf("%lld", &(x))
      |               ~~~~~^~~~~~~~~~~~~~
Main.cpp:46:5: note: in expansion of macro ‘rd’
   46 |     rd(n), rd(m);
      |     ^~
Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define rd(x) scanf("%lld", &(x))
      |               ~~~~~^~~~~~~~~~~~~~
Main.cpp:46:12: note: in expansion of macro ‘rd’
   46 |     rd(n), rd(m);
      |            ^~
Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define rd(x) scanf("%lld", &(x))
      |               ~~~~~^~~~~~~~~~~~~~
Main.cpp:47:18: note: in expansion of macro ‘rd’
   47 |     rep(i, 1, n) rd(a[i]);
      |                  ^~
Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define rd(x) scanf("%lld", &(x))
      |               ~~~~~^~~~~~~~~~~~~~
Main.cpp:49:9: note: in expansion of macro ‘rd’
   49 |         rd(s);
      |         ^~
Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define rd(x) scanf("%lld", &(x))
      |               ~~~~~^~~~~~~~~~~~~~
Main.cpp:50:16: note: in expansion of macro ‘rd’
   50 |         cir(s) rd(x), vis[x][i] = true;
      |                ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 35
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3640 KiB
hand_02.txt AC 1 ms 3592 KiB
hand_03.txt AC 1 ms 3772 KiB
random_01.txt AC 12 ms 3712 KiB
random_02.txt AC 11 ms 3832 KiB
random_03.txt AC 9 ms 3772 KiB
random_04.txt AC 11 ms 3776 KiB
random_05.txt AC 2 ms 3712 KiB
random_06.txt AC 1 ms 3668 KiB
random_07.txt AC 16 ms 3636 KiB
random_08.txt AC 1 ms 3548 KiB
random_09.txt AC 2 ms 3776 KiB
random_10.txt AC 1 ms 3588 KiB
random_11.txt AC 11 ms 3660 KiB
random_12.txt AC 1 ms 3636 KiB
random_13.txt AC 2 ms 3648 KiB
random_14.txt AC 1 ms 3644 KiB
random_15.txt AC 11 ms 3588 KiB
random_16.txt AC 1 ms 3636 KiB
random_17.txt AC 2 ms 3656 KiB
random_18.txt AC 1 ms 3584 KiB
random_19.txt AC 2 ms 3708 KiB
random_20.txt AC 2 ms 3836 KiB
random_21.txt AC 1 ms 3832 KiB
random_22.txt AC 2 ms 3552 KiB
random_23.txt AC 1 ms 3832 KiB
random_24.txt AC 1 ms 3772 KiB
random_25.txt AC 1 ms 3720 KiB
random_26.txt AC 2 ms 3768 KiB
random_27.txt AC 1 ms 3656 KiB
random_28.txt AC 1 ms 3552 KiB
random_29.txt AC 1 ms 3728 KiB
random_30.txt AC 1 ms 3836 KiB
sample_01.txt AC 1 ms 3712 KiB
sample_02.txt AC 1 ms 3728 KiB