# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
385216 |
2021-04-03T17:19:27 Z |
ritul_kr_singh |
PIN (CEOI10_pin) |
C++17 |
|
466 ms |
1952 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
int mask;
bool comp(string x, string y){
for(int i=0; i<4; ++i){
if(((1<<i)&mask) and x[i]!=y[i]) return x[i]<y[i];
}
return false;
}
bool equal(string x, string y){
return comp(x, y)==comp(y, x);
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n, d; cin >> n >> d;
string a[n]; for(auto &i : a) cin >> i;
int ans[5] = {};
int c[5][5];
c[4][0] = c[4][4] = 1, c[4][1] = c[4][3] = 4, c[4][2] = 6;
c[3][0] = c[3][3] = 1, c[3][1] = c[3][2] = 3;
c[2][0] = c[2][2] = 1, c[2][1] = 2;
c[1][0] = c[1][1] = 1;
for(mask=0; mask<16; ++mask){
int cnt = 0;
for(int i=0; i<4; ++i) if((1<<i)&mask) ++cnt;
sort(a, a+n, comp);
for(int i=0; i<n; ++i){
int j = i;
while(j+1<n and equal(a[i], a[j+1])) ++j;
ans[cnt] += ((j-i+1)*(j-i))/2;
i = j;
}
}
int j = -1, res = 0;
for(int i=4-d; i<5; ++i){
j = -j;
res += ans[i] * j;
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
364 KB |
Output is correct |
2 |
Incorrect |
13 ms |
364 KB |
Output isn't correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
162 ms |
1132 KB |
Output is correct |
5 |
Correct |
207 ms |
1260 KB |
Output is correct |
6 |
Incorrect |
227 ms |
1164 KB |
Output isn't correct |
7 |
Incorrect |
161 ms |
1132 KB |
Output isn't correct |
8 |
Correct |
225 ms |
1132 KB |
Output is correct |
9 |
Correct |
383 ms |
1900 KB |
Output is correct |
10 |
Incorrect |
466 ms |
1936 KB |
Output isn't correct |
11 |
Incorrect |
223 ms |
1260 KB |
Output isn't correct |
12 |
Incorrect |
440 ms |
1772 KB |
Output isn't correct |
13 |
Incorrect |
248 ms |
1260 KB |
Output isn't correct |
14 |
Correct |
221 ms |
1132 KB |
Output is correct |
15 |
Correct |
421 ms |
1772 KB |
Output is correct |
16 |
Correct |
315 ms |
1388 KB |
Output is correct |
17 |
Incorrect |
462 ms |
1900 KB |
Output isn't correct |
18 |
Correct |
337 ms |
1572 KB |
Output is correct |
19 |
Correct |
436 ms |
1772 KB |
Output is correct |
20 |
Correct |
466 ms |
1952 KB |
Output is correct |