Submission #575746

# Submission time Handle Problem Language Result Execution time Memory
575746 2022-06-11T08:43:24 Z AGE Parametriziran (COCI19_parametriziran) C++14
22 / 110
3000 ms 35784 KB
#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++){

        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++){
                string sss;
                sss=ss+y;
                if(x!=s[i][0]&&y!=s[i][1]){
                    ans+=mp[sss];
                }

            }
        }
    }

    cout<<ans/2<<endl;
    return 0;
}

Compilation message

parametriziran.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3077 ms 31748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1320 ms 31740 KB Output is correct
2 Correct 386 ms 31744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 894 ms 31788 KB Output is correct
2 Correct 2251 ms 31804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2206 ms 32732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1656 ms 32656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3070 ms 35276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2559 ms 34508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 35120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3080 ms 34336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 35784 KB Time limit exceeded
2 Halted 0 ms 0 KB -