답안 #135348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135348 2019-07-24T04:02:32 Z 김세빈(#3248) PIN (CEOI10_pin) C++14
100 / 100
73 ms 7052 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector <ll> V[22];
char S[11], T[11];
ll D[11];
ll n, d;

int main()
{
	ll i, j, k, s;
	
	scanf("%lld%lld", &n, &d);
	
	for(i=0; i<n; i++){
		scanf("%s", S);
		for(j=0; j<4; j++){
			if('0' <= S[j] && S[j] <= '9') T[j] = S[j] - '0';
			else T[j] = S[j] - 'a' + 10;
		}
		for(j=0; j<16; j++){
			for(k=0, s=0; k<4; k++){
				s = s * 36;
				if(~j & (1 << k)){
					s += T[k];
				}
			}
			V[j].push_back(s);
		}
	}
	
	for(i=1; i<16; i++){
		for(j=0, s=0; j<4; j++){
			if(i & (1 << j)) s ++;
		}
		sort(V[i].begin(), V[i].end());
		for(j=0; j<V[i].size(); j=k){
			for(k=j; k<V[i].size() && V[i][j] == V[i][k]; k++);
			D[s] += (k - j) * (k - j - 1) / 2;
		}
	}
	
	D[2] -= D[1] * 3;
	D[3] -= D[2] * 2 + D[1] * 3;
	D[4] -= D[3] + D[2] + D[1];
	
	printf("%lld\n", D[d]);
	
	return 0;
}

Compilation message

pin.cpp: In function 'int main()':
pin.cpp:40:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0; j<V[i].size(); j=k){
            ~^~~~~~~~~~~~
pin.cpp:41:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(k=j; k<V[i].size() && V[i][j] == V[i][k]; k++);
             ~^~~~~~~~~~~~
pin.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &d);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
pin.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", S);
   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 508 KB Output is correct
4 Correct 28 ms 3648 KB Output is correct
5 Correct 31 ms 4184 KB Output is correct
6 Correct 31 ms 4200 KB Output is correct
7 Correct 25 ms 3540 KB Output is correct
8 Correct 33 ms 4440 KB Output is correct
9 Correct 55 ms 6292 KB Output is correct
10 Correct 62 ms 6972 KB Output is correct
11 Correct 33 ms 4312 KB Output is correct
12 Correct 59 ms 6672 KB Output is correct
13 Correct 36 ms 4696 KB Output is correct
14 Correct 33 ms 4312 KB Output is correct
15 Correct 59 ms 6748 KB Output is correct
16 Correct 47 ms 5568 KB Output is correct
17 Correct 73 ms 7052 KB Output is correct
18 Correct 54 ms 5568 KB Output is correct
19 Correct 70 ms 6296 KB Output is correct
20 Correct 69 ms 7052 KB Output is correct