Submission #145127

# Submission time Handle Problem Language Result Execution time Memory
145127 2019-08-18T21:13:14 Z radugheo Mate (COCI18_mate) C++14
0 / 100
1921 ms 24444 KB
#include <bits/stdc++.h>

using namespace std;

int l, i, j, q, k, a, x, p;
int r[2005][30], c[2005][30];
int d[2005][30][30], sol[2005][30][30];

char y, z, s[2005];

vector <int> v[30];

int main(){
    cin >> (s + 1);
    l = strlen(s+1);
    c[0][0] = 1;
    for (i=1; i<=l; i++){
        c[i][0] = 1;
        for (j=1; j<=i; j++){
            c[i][j] = c[i-1][j-1] + c[i-1][j];
        }
    }
    for (i=1; i<=l; i++){
        v[s[i] - 'a'].push_back(i);
    }
    for (i=l; i>=1; i--){
        for (j=0; j<26; j++){
            if (s[i] == j + 'a'){
                r[i][j] = 1 + r[i+1][j];
            }
            else{
                r[i][j] = r[i+1][j];
            }
        }
    }
    for (i=l; i>=1; i--){
        for (j=0; j<26; j++){
            for (q=0; q<26; q++){
                if (s[i] == j + 'a'){
                    d[i][j][q] = r[i+1][q];
                }
                else{
                    d[i][j][q] = d[i+1][j][q];
                }
            }
        }
    }
    for (i=2; i<=l; i++){
        for (j=0; j<26; j++){
            for (q=0; q<v[j].size(); q++){
                p = v[j][q];
                if (p >= i - 1){
                    for (k=0; k<26; k++){
                        sol[i][j][k] += d[p][j][k] * c[p-1][i-2];
                    }
                }
            }
        }
    }
    cin >> a;
    for (i=1; i<=a; i++){
        cin >> x >> y >> z;
        cout << sol[x][y-'a'][z-'a'] << "\n";
    }
    return 0;
}

Compilation message

mate.cpp: In function 'int main()':
mate.cpp:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (q=0; q<v[j].size(); q++){
                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 1016 KB Output isn't correct
2 Incorrect 57 ms 888 KB Output isn't correct
3 Incorrect 70 ms 760 KB Output isn't correct
4 Incorrect 114 ms 1016 KB Output isn't correct
5 Incorrect 423 ms 3704 KB Output isn't correct
6 Incorrect 484 ms 3960 KB Output isn't correct
7 Incorrect 378 ms 3576 KB Output isn't correct
8 Incorrect 330 ms 3192 KB Output isn't correct
9 Incorrect 1910 ms 24444 KB Output isn't correct
10 Incorrect 1921 ms 24316 KB Output isn't correct