| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1001621 | vjudge1 | Dabbeh (INOI20_dabbeh) | C++17 | 60 ms | 15456 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 3e5 + 5;
int n, q;
string s;
string t[MAX];
int to[MAX][27][27];
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++){
            if(j >= s.size()) break;
            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();
    }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
