# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575668 | AGE | Parametriziran (COCI19_parametriziran) | C++14 | 3064 ms | 34624 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=1e6,M=2e3,mod=1e9+7;
string s[N];
map<string,int>mp;
int cnt[N][27];
main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>s[i];
int ans=n*(n-1);
for(int i=0;i<n;i++){
if(s[i][0]!='?')
cnt[0][s[i][0]-'a']++;
if(s[i][1]!='?')
cnt[1][s[i][1]-'a']++;
}
int sum0=0;
for(int i=0;i<26;i++)
sum0+=cnt[0][i];
for(int i=0;i<n;i++)
if(s[i][0]!='?')
ans-=(sum0-cnt[0][s[i][0]-'a']);
int sum1=0;
for(int i=0;i<26;i++)
sum1+=cnt[1][i];
for(int i=0;i<n;i++)
if(s[i][1]!='?')
ans-=(sum1-cnt[1][s[i][1]-'a']);
int cntt=0;
for(int i=0;i<n;i++){
if(s[i][0]!='?'&&s[i][1]!='?')
cntt++,mp[s[i]]++;
}
for(int i=0;i<n;i++){
if(s[i][0]=='?'||s[i][1]=='?')
continue;
for(char x='a';x<='z';x++){
string ss;
ss.clear();
ss+=x;
for(char y='a';y<='z';y++){
ss+=y;
if(x!=s[i][0]&&y!=s[i][1])
ans+=mp[ss];
}
}
}
cout<<ans/2<<endl;
return 0;
}
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... |