답안 #856470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856470 2023-10-03T15:37:24 Z MilosMilutinovic PIN (CEOI10_pin) C++14
30 / 100
325 ms 15200 KB
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,d;
char s[50005][4];

int main(){
	scanf("%d%d",&n,&d); d=4-d;
	for(int i=1;i<=n;i++) scanf("%s",s+i);
	map<string,int> cnt;
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int mask=(1<<4)-1;mask>=0;mask--){
			int pc=__builtin_popcount(mask);
			if(pc<d) continue;
			string str="";
			for(int j=0;j<4;j++) if(mask>>j&1) str+=s[i][j]; else str+='*';
			ans+=cnt[str]*(d%pc==0?1:-1);
		}
		for(int mask=0;mask<(1<<4);mask++){
			string str="";
			for(int j=0;j<4;j++) if(mask>>j&1) str+=s[i][j]; else str+='*';
			cnt[str]+=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

pin.cpp: In function 'int main()':
pin.cpp:25:32: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4]' [-Wformat=]
   25 |  for(int i=1;i<=n;i++) scanf("%s",s+i);
      |                               ~^  ~~~
      |                                |   |
      |                                |   char (*)[4]
      |                                char*
pin.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d",&n,&d); d=4-d;
      |  ~~~~~^~~~~~~~~~~~~~
pin.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(int i=1;i<=n;i++) scanf("%s",s+i);
      |                        ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1116 KB Output is correct
2 Incorrect 7 ms 1036 KB Output isn't correct
3 Runtime error 1 ms 344 KB Execution killed with signal 8
4 Correct 78 ms 3488 KB Output is correct
5 Correct 97 ms 3768 KB Output is correct
6 Incorrect 125 ms 3896 KB Output isn't correct
7 Incorrect 97 ms 3412 KB Output isn't correct
8 Correct 109 ms 4172 KB Output is correct
9 Correct 180 ms 5584 KB Output is correct
10 Incorrect 246 ms 6120 KB Output isn't correct
11 Incorrect 130 ms 3912 KB Output isn't correct
12 Incorrect 249 ms 5808 KB Output isn't correct
13 Incorrect 167 ms 4340 KB Output isn't correct
14 Runtime error 2 ms 856 KB Execution killed with signal 8
15 Runtime error 3 ms 1116 KB Execution killed with signal 8
16 Correct 181 ms 11228 KB Output is correct
17 Incorrect 325 ms 15200 KB Output isn't correct
18 Runtime error 2 ms 856 KB Execution killed with signal 8
19 Runtime error 3 ms 1112 KB Execution killed with signal 8
20 Runtime error 4 ms 1116 KB Execution killed with signal 8