Submission #598333

# Submission time Handle Problem Language Result Execution time Memory
598333 2022-07-18T05:23:57 Z AGE Parametriziran (COCI19_parametriziran) C++14
33 / 110
716 ms 10536 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=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

parametriziran.cpp:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 137 ms 6984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 6836 KB Output is correct
2 Correct 201 ms 6860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 242 ms 6916 KB Output is correct
2 Correct 232 ms 7256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 7628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 716 ms 7500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 339 ms 10212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 9264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 240 ms 10020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 248 ms 9180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 458 ms 10536 KB Output isn't correct
2 Halted 0 ms 0 KB -