Submission #598331

# Submission time Handle Problem Language Result Execution time Memory
598331 2022-07-18T05:14:19 Z AGE Parametriziran (COCI19_parametriziran) C++14
0 / 110
648 ms 10836 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];
        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][1];
        z+=x;
        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];

        mp[s[i]]++;

    }

    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:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 6652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 6688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 6716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 7592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 648 ms 7452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 10220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 345 ms 9376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 10104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 9356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 376 ms 10836 KB Output isn't correct
2 Halted 0 ms 0 KB -