# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
135387 |
2019-07-24T04:37:21 Z |
송준혁(#3252) |
PIN (CEOI10_pin) |
C++14 |
|
360 ms |
632 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int N, D;
int A[101010];
int T[5] = {1, 36, 1296, 46656};
LL P[20];
int toint(char ch){
if ('0' <= ch && ch <= '9') return ch - '0';
return 9 + ch - 'a';
}
bool comp(int a, int b, int k){
for (int i=0; i<4; i++){
if ((k & (1<<i)) && a/T[i]%36 != b/T[i]%36) return a/T[i]%36 < b/T[i]%36;
}
return false;
}
int main(){
scanf("%d %d", &N, &D);
for (int i=1; i<=N; i++){
for (int j=0; j<4; j++){
char ch;
scanf(" %c", &ch);
A[i] = A[i]*36 + toint(ch);
}
}
for (int i=1; i<15; i++){
sort(A+1, A+N+1, [&](int a, int b){return comp(a, b, i);});
int p=1, q=1;
while (p<=N){
while (q < N && !comp(A[p], A[q+1], i) && !comp(A[q+1], A[p], i)) q++;
P[i] += (q-p+1) * (q-p) / 2;
p = q+1, q = p;
}
}
if (D == 4) printf("%lld\n", N*(N-1)/2 - ((P[1]+P[2]+P[4]+P[8])-2*((P[3]+P[5]+P[9]+P[6]+P[10]+P[12])-3*(P[14]+P[13]+P[11]+P[7]))-3*(P[14]+P[13]+P[11]+P[7]))-((P[3]+P[5]+P[9]+P[6]+P[10]+P[12])-3*(P[14]+P[13]+P[11]+P[7]))-(P[14]+P[13]+P[11]+P[7]));
if (D == 3) printf("%lld\n", (P[1]+P[2]+P[4]+P[8])-2*((P[3]+P[5]+P[9]+P[6]+P[10]+P[12])-3*(P[14]+P[13]+P[11]+P[7]))-3*(P[14]+P[13]+P[11]+P[7]));
if (D == 2) printf("%lld\n", (P[3]+P[5]+P[9]+P[6]+P[10]+P[12])-3*(P[14]+P[13]+P[11]+P[7]));
if (D == 1) printf("%lld\n", P[14]+P[13]+P[11]+P[7]);
return 0;
}
Compilation message
pin.cpp: In function 'int main()':
pin.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &N, &D);
~~~~~^~~~~~~~~~~~~~~~~
pin.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c", &ch);
~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
9 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
131 ms |
436 KB |
Output isn't correct |
5 |
Incorrect |
164 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
163 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
130 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
190 ms |
508 KB |
Output isn't correct |
9 |
Incorrect |
309 ms |
504 KB |
Output isn't correct |
10 |
Incorrect |
342 ms |
560 KB |
Output isn't correct |
11 |
Incorrect |
175 ms |
504 KB |
Output isn't correct |
12 |
Incorrect |
317 ms |
556 KB |
Output isn't correct |
13 |
Incorrect |
198 ms |
504 KB |
Output isn't correct |
14 |
Incorrect |
179 ms |
476 KB |
Output isn't correct |
15 |
Incorrect |
320 ms |
544 KB |
Output isn't correct |
16 |
Incorrect |
234 ms |
504 KB |
Output isn't correct |
17 |
Incorrect |
359 ms |
560 KB |
Output isn't correct |
18 |
Incorrect |
267 ms |
504 KB |
Output isn't correct |
19 |
Incorrect |
321 ms |
632 KB |
Output isn't correct |
20 |
Incorrect |
360 ms |
504 KB |
Output isn't correct |