Submission #65438336


Source Code Expand

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

#define ll long long
#define db double
#define i128 __int128
#define ui unsigned int
#define ull unsigned long long

mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const ull X=rng_64();
ull splitmix64(ull x) {
	x^=x<<13;
	x^=x>>7;
	x^=x<<17;
	return x;
}
ull rng(ull x){return splitmix64(x+X);}

const int N=20;
const int M=100; 
int n,m;
ll c[(1<<N)+10];
int val[(1<<N)+10][M+2];
int lowbit(int x){return x&(-x);}

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>c[(1<<2*i)];
		c[(1<<(2*i+1))]=c[(1<<2*i)]; 
	}
	for(int i=1;i<=m;i++){
		int k;
		cin>>k;
		for(int j=1;j<=k;j++){
			int x;
			cin>>x;
			x--;
			val[(1<<2*x)][i]=1;
			val[(1<<2*x+1)][i]=1;
		}
	}
	n=n*2;
	ll ans=1e18;
	for(int i=0;i<(1<<n);i++){
		if(i!=lowbit(i)){
			for(int j=1;j<=m;j++)
				val[i][j]=val[i^lowbit(i)][j]+val[lowbit(i)][j];
			c[i]=c[i^lowbit(i)]+c[lowbit(i)];
		}
		bool is1=true;
		for(int j=1;j<=m;j++) is1&=(val[i][j]>=2);
		if(is1) ans=min(ans,c[i]);
	}
	cout<<ans;
	return 0;
}
/*
W [20:15(read wrong),20:18]
C [20:18,20:20](n=n*2)

Cyber malody E judge fc choke.

g++ test.cpp -o test -std=c++14 -O2 -Wall -Wshadow ulimit -s 5120000
./test
*/

Submission Info

Submission Time
Task D - Goin' to the Zoo
User BigPigeon_fan
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1394 Byte
Status AC
Exec Time 258 ms
Memory 429604 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:43:36: warning: suggest parentheses around ‘+’ inside ‘<<’ [-Wparentheses]
   43 |                         val[(1<<2*x+1)][i]=1;
      |                                 ~~~^~

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 3 ms 10136 KiB
hand_02.txt AC 1 ms 3504 KiB
hand_03.txt AC 1 ms 3580 KiB
random_01.txt AC 255 ms 429344 KiB
random_02.txt AC 258 ms 429452 KiB
random_03.txt AC 255 ms 429480 KiB
random_04.txt AC 255 ms 429564 KiB
random_05.txt AC 148 ms 429468 KiB
random_06.txt AC 40 ms 109984 KiB
random_07.txt AC 256 ms 429528 KiB
random_08.txt AC 2 ms 5236 KiB
random_09.txt AC 147 ms 429532 KiB
random_10.txt AC 1 ms 3904 KiB
random_11.txt AC 258 ms 429476 KiB
random_12.txt AC 1 ms 3784 KiB
random_13.txt AC 151 ms 429340 KiB
random_14.txt AC 2 ms 5232 KiB
random_15.txt AC 258 ms 429528 KiB
random_16.txt AC 1 ms 3724 KiB
random_17.txt AC 154 ms 429604 KiB
random_18.txt AC 1 ms 4032 KiB
random_19.txt AC 156 ms 429480 KiB
random_20.txt AC 154 ms 429344 KiB
random_21.txt AC 4 ms 10020 KiB
random_22.txt AC 152 ms 429400 KiB
random_23.txt AC 4 ms 10140 KiB
random_24.txt AC 39 ms 109984 KiB
random_25.txt AC 4 ms 10132 KiB
random_26.txt AC 152 ms 429532 KiB
random_27.txt AC 4 ms 10272 KiB
random_28.txt AC 11 ms 30096 KiB
random_29.txt AC 10 ms 30088 KiB
random_30.txt AC 39 ms 109988 KiB
sample_01.txt AC 1 ms 3652 KiB
sample_02.txt AC 4 ms 10148 KiB