結果

問題 No.2178 Payable Magic Items
ユーザー kotatsugamekotatsugame
提出日時 2023-01-06 21:49:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,070 ms / 4,000 ms
コード長 738 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 65,456 KB
実行使用メモリ 5,732 KB
最終ジャッジ日時 2023-08-21 08:15:43
合計ジャッジ時間 30,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,014 ms
4,916 KB
testcase_01 AC 1,016 ms
5,184 KB
testcase_02 AC 1,018 ms
4,920 KB
testcase_03 AC 1,023 ms
4,852 KB
testcase_04 AC 1,018 ms
5,176 KB
testcase_05 AC 1,016 ms
4,908 KB
testcase_06 AC 1,017 ms
4,860 KB
testcase_07 AC 1,016 ms
5,028 KB
testcase_08 AC 1,016 ms
4,892 KB
testcase_09 AC 1,014 ms
4,852 KB
testcase_10 AC 1,015 ms
4,860 KB
testcase_11 AC 1,067 ms
5,676 KB
testcase_12 AC 1,069 ms
5,696 KB
testcase_13 AC 1,070 ms
5,664 KB
testcase_14 AC 1,066 ms
5,664 KB
testcase_15 AC 1,069 ms
5,636 KB
testcase_16 AC 1,070 ms
5,684 KB
testcase_17 AC 1,031 ms
5,112 KB
testcase_18 AC 1,015 ms
5,200 KB
testcase_19 AC 1,027 ms
5,036 KB
testcase_20 AC 1,016 ms
4,928 KB
testcase_21 AC 1,012 ms
4,968 KB
testcase_22 AC 1,013 ms
5,112 KB
testcase_23 AC 1,013 ms
4,856 KB
testcase_24 AC 1,051 ms
5,732 KB
testcase_25 AC 1,022 ms
5,016 KB
testcase_26 AC 1,039 ms
5,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int N,K;
int S[2<<17];
int C[390625];
int main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		string s;cin>>s;
		int t=0;
		for(int j=0;j<8;j++)
		{
			t*=5;
			if(j<K)t+=4-(s[j]-'0');
		}
		S[i]=t;
		C[t]++;
	}
	for(int i=0;i<390625;i++)
	{
		int v[8];
		{
			int u=i;
			for(int j=0;j<8;j++)v[7-j]=u%5,u/=5;
		}
		int now=0;
		for(int j=0;j<1<<8;j++)
		{
			int t=0,c=0;
			bool ok=true;
			for(int k=0;k<8;k++)
			{
				t*=5;
				if(j>>k&1)
				{
					c++;
					if(v[k]==0){ok=false;break;}
					t+=v[k]-1;
				}
				else t+=v[k];
			}
			if(ok)
			{
				if(c>0&&c%2==0)now-=C[t];
				else now+=C[t];
			}
		}
		C[i]=now;
	}
	int ans=0;
	for(int i=0;i<N;i++)if(C[S[i]]>=2)ans++;
	cout<<ans<<endl;
}
0