Created
May 28, 2016 05:38
-
-
Save viliml/e5693e9de590229b4662d53a94001b8f to your computer and use it in GitHub Desktop.
CEOI 2010, day 2, task PIN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
map<string, int> num1[4], num2[6], num3[4]; | |
string get1(string str, int type) | |
{ | |
str.erase(type, 1); | |
return str; | |
} | |
string get2(string str, int type) | |
{ | |
str.erase(type + 1 - 2 * (type > 2) - (type > 4), 1); | |
str.erase((type > 2) + (type > 4), 1); | |
return str; | |
} | |
string get3(string str, int type) | |
{ | |
return string(1, str[type]); | |
} | |
int main() | |
{ | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
int n, d, i, num, sol = 0; | |
string str; | |
int x1, x2, x3; | |
cin>>n>>d; | |
for (i = 0; i < n; ++i) | |
{ | |
cin>>str; | |
num = 1; | |
x1 = 0; | |
for (int k = 0; k < 4; ++k) | |
{ | |
x1 += ++num1[k][get1(str, k)]; | |
} | |
num = x1 = x1 - 4 * 1; | |
if (d == 1) | |
goto end; | |
x2 = 0; | |
for (int k = 0; k < 6; ++k) | |
{ | |
x2 += ++num2[k][get2(str, k)]; | |
} | |
num = x2 = x2 - 3 * x1 - 6 * 1; | |
if (d == 2) | |
goto end; | |
x3 = 0; | |
for (int k = 0; k < 4; ++k) | |
{ | |
x3 += ++num3[k][get3(str, k)]; | |
} | |
num = x3 = x3 - 2 * x2 - 3 * x1 - 4 * 1; | |
if (d == 3) | |
goto end; | |
num = i + 1 - x3 - x2 - x1 - 1; | |
end: | |
sol += num; | |
// cout<<num<<endl; | |
} | |
cout<<sol<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment