Submission #1001572

# Submission time Handle Problem Language Result Execution time Memory
1001572 2024-06-19T05:59:30 Z vjudge1 Dabbeh (INOI20_dabbeh) C++17
0 / 100
57 ms 7688 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define oo 1e9
const int MAX = 1e4 + 5;

int n, q;
string s;
string t[MAX];

int to[MAX][27][26];
void solve(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> t[i];
        t[i] = '{' + t[i];
    }
    cin >> s;
    s = '{' + s;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= t[i].size() - 1; j++){
            to[j - 1][t[i][j - 1] - 'a'][t[i][j] - 'a'] = 1;
            // cout << j - 1 << ' ' << t[i][j - 1] - 'a' << ' ' << t[i][j] - 'a' << '\n';
        }
    }
    while(q--){
        int l, r; cin >> l >> r;
        l++;
        int ans = 1;
        int i = 0, c = 26;
        while(true){
            if(l == r + 1) break;
            if(to[i][c][s[l] - 'a']){
                c = s[l] - 'a';
                i++;
                l++;
            }
            else if(!to[0][26][s[l] - 'a']){
                ans = -1;
                break;
            }
            else{
                ans++;
                i = 0, c = 26;
            }
        }
        cout << ans << '\n';
    }
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
        solve();
    }
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:25:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int j = 1; j <= t[i].size() - 1; j++){
      |                        ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Incorrect 57 ms 7688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Incorrect 57 ms 7688 KB Output isn't correct
3 Halted 0 ms 0 KB -