Submission #1001572

#TimeUsernameProblemLanguageResultExecution timeMemory
1001572vjudge1Dabbeh (INOI20_dabbeh)C++17
0 / 100
57 ms7688 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...