結果

問題 No.2178 Payable Magic Items
ユーザー kotatsugamekotatsugame
提出日時 2023-01-09 18:28:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 4,000 ms
コード長 417 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 64,508 KB
実行使用メモリ 5,812 KB
最終ジャッジ日時 2023-08-22 19:58:03
合計ジャッジ時間 3,747 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,968 KB
testcase_01 AC 12 ms
4,864 KB
testcase_02 AC 12 ms
4,844 KB
testcase_03 AC 12 ms
4,868 KB
testcase_04 AC 11 ms
5,040 KB
testcase_05 AC 12 ms
4,864 KB
testcase_06 AC 12 ms
4,860 KB
testcase_07 AC 12 ms
4,912 KB
testcase_08 AC 11 ms
4,860 KB
testcase_09 AC 11 ms
4,860 KB
testcase_10 AC 11 ms
4,860 KB
testcase_11 AC 63 ms
5,812 KB
testcase_12 AC 62 ms
5,708 KB
testcase_13 AC 63 ms
5,636 KB
testcase_14 AC 62 ms
5,612 KB
testcase_15 AC 62 ms
5,696 KB
testcase_16 AC 62 ms
5,688 KB
testcase_17 AC 28 ms
5,416 KB
testcase_18 AC 12 ms
4,852 KB
testcase_19 AC 22 ms
5,044 KB
testcase_20 AC 11 ms
4,840 KB
testcase_21 AC 12 ms
4,844 KB
testcase_22 AC 13 ms
4,872 KB
testcase_23 AC 11 ms
4,864 KB
testcase_24 AC 48 ms
5,568 KB
testcase_25 AC 19 ms
4,960 KB
testcase_26 AC 27 ms
5,168 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,t=1;i<8;i++,t*=5)
	{
		for(int j=0;j+t<390625;j++)if(j%(t*5)<4*t)C[j+t]+=C[j];
	}
	int ans=0;
	for(int i=0;i<N;i++)if(C[S[i]]>=2)ans++;
	cout<<ans<<endl;
}
0