# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486401 | Rainbowbunny | PIN (CEOI10_pin) | C++17 | 221 ms | 24708 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
int pw[10];
int n, d;
int cnt[10], tt[10];
string s[MAXN];
map <int, int> M[30];
int Get(char c)
{
if(c >= '0' and c <= '9')
{
return c - '0';
}
else
{
return c - 'a' + 10;
}
}
int main()
{
// freopen("Input.txt", "r", stdin);
// freopen("Output2.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
pw[0] = 1;
for(int i = 1; i <= 3; i++)
{
pw[i] = pw[i - 1] * 36;
}
cin >> n >> d;
for(int i = 1; i <= n; i++)
{
cin >> s[i];
for(int j = 0; j <= 4; j++)
{
tt[j] = 0;
}
for(int j = 0; j < 1 << 4; j++)
{
int cur = 0;
for(int k = 0; k < 4; k++)
{
if(!(j & (1 << k)))
{
cur += pw[k] * Get(s[i][k]);
}
}
tt[__builtin_popcount(j)] += M[j][cur];
M[j][cur]++;
}
for(int j = 1; j <= 4; j++)
{
// cout << tt[j] << ' ';
}
tt[1] -= 4 * tt[0];
tt[2] -= 3 * tt[1];
tt[2] -= 6 * tt[0];
tt[3] -= 4 * tt[0];
tt[3] -= 3 * tt[1];
tt[3] -= 2 * tt[2];
tt[4] = (i - 1) - tt[0] - tt[1] - tt[2] - tt[3];
for(int j = 0; j <= 4; j++)
{
cnt[j] += tt[j];
}
// cout << '\n';
for(int j = 0; j <= 4; j++)
{
// cout << tt[j] << ' ';
}
// cout << '\n';
}
cout << cnt[d] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |