# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598333 | AGE | Parametriziran (COCI19_parametriziran) | C++14 | 716 ms | 10536 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 F first
#define S second
#define int long long
#define pb push_back
using namespace std;
const int N=2e5+10,M=2e3,mod=1e9+7;
string s[N];
map<string,int>mp;
int ans=0;
void doo1char(int index){
string z;
for(int i=0;i<26;i++){
char x=i+'a';
z=x;
z+=s[index][1];
if(s[index][1]!='?')
ans+=mp[z];
z=x;
z+='?';
ans+=mp[z];
}
}
void doochar1(int index){
string z;
for(int i=0;i<26;i++){
char x=i+'a';
z=s[index][0];
z+=x;
if(s[index][0]!='?')
ans+=mp[z];
z='?';
z+=x;
ans+=mp[z];
}
}
void doo11(int index){
string z;
for(int i=0;i<26;i++){
for(int j=0;j<26;j++){
char x=i+'a';
char y=j+'a';
z=x;
z+=y;
ans+=mp[z];
}
}
}
main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>s[i];
for(int i=0;i<n;i++){
if(s[i][0]=='?'){
doo1char(i);
}
if(s[i][1]=='?'){
doochar1(i);
}
if(s[i][1]=='?'&&s[i][0]=='?'){
doo11(i);
ans+=mp[s[i]];
mp[s[i]]++;
continue;
}
if(s[i][0]!='?'&&s[i][1]!='?'){
string z;
z=s[i][0];
z+='?';
ans+=mp[z];
z='?';
z+=s[i][1];
ans+=mp[z];
}
string z;
z+='?';
z+='?';
ans+=mp[z];
ans+=mp[s[i]];
mp[s[i]]++;
cerr<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}
/*
8
1 2
2 3
2 4
4 5
2 6
6 7
7 8
1
4
3 6 7 8
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |