# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135398 |
2019-07-24T04:50:02 Z |
송준혁(#3252) |
PIN (CEOI10_pin) |
C++14 |
|
363 ms |
636 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, 40, 1600, 64000};
LL P[20];
int toint(char ch){
if ('0' <= ch && ch <= '9') return ch - '0';
return 10 + 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]*40 + toint(ch);
}
}
for (int i=1; i<15; i++){
sort(A+1, A+N+1, [&](int a, int b){return comp(a, b, i);});
LL 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", (LL)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);
~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
8 ms |
380 KB |
Output isn't correct |
4 |
Incorrect |
134 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
168 ms |
456 KB |
Output isn't correct |
6 |
Incorrect |
165 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
132 ms |
536 KB |
Output isn't correct |
8 |
Incorrect |
186 ms |
468 KB |
Output isn't correct |
9 |
Incorrect |
304 ms |
536 KB |
Output isn't correct |
10 |
Incorrect |
341 ms |
556 KB |
Output isn't correct |
11 |
Incorrect |
178 ms |
504 KB |
Output isn't correct |
12 |
Incorrect |
324 ms |
636 KB |
Output isn't correct |
13 |
Incorrect |
203 ms |
540 KB |
Output isn't correct |
14 |
Incorrect |
183 ms |
464 KB |
Output isn't correct |
15 |
Incorrect |
324 ms |
544 KB |
Output isn't correct |
16 |
Incorrect |
235 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
362 ms |
556 KB |
Output isn't correct |
18 |
Incorrect |
273 ms |
504 KB |
Output isn't correct |
19 |
Incorrect |
322 ms |
504 KB |
Output isn't correct |
20 |
Incorrect |
363 ms |
504 KB |
Output isn't correct |