# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951862 | Saul0906 | PIN (CEOI10_pin) | C++14 | 345 ms | 26596 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>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
#define endl "\n"
using namespace std;
struct trie{
trie *nxt[36];
int cont=0;
} *TR = new trie;
void add(string s){
trie *act=TR;
int x;
rep(i,0,s.size()){
if(s[i]>'9' || s[i]<'0') x=s[i]-'a'+10;
else x=s[i]-'0';
if(!(act->nxt[x])) act->nxt[x]=new trie;
act=act->nxt[x];
act->cont++;
}
}
int find(string s){
trie *act=TR;
int x;
rep(i,0,s.size()){
if(s[i]>'9' || s[i]<'0') x=s[i]-'a'+10;
else x=s[i]-'0';
if(!(act->nxt[x])) return 0;
act=act->nxt[x];
}
return act->cont;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, d, ans=0;
cin>>n>>d;
string s[n], t;
rep(i,0,n){
cin>>s[i];
t=s[i];
rep(k,0,4){
rep(j,0,10) if(j+'0'!=s[i][k]) t[k]=j+'0', ans+=find(t);
rep(j,0,26) if(j+'a'!=s[i][k]) t[k]=j+'a', ans+=find(t);
t[k]=s[i][k];
}
add(t);
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |