Submission #2076217
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() const int MN = 500010; int tor[MN][27]; //26 for "" int nx[20][MN]; int main() { string s; cin >> s; int n = s.size(); rep(i, 27) tor[n][i] = MN; for (int i = n-1; i >= 0; --i) { int c = s[i] - 'a'; tor[i][c] = i + 1; for (int j = c + 1; j < 27; ++j) { tor[i][j] = (tor[i][j-1] == MN ? MN : tor[tor[i][j-1]][j-1]); } nx[0][i] = tor[i][26]; for (int j = 0; j < c; ++j) { tor[i][j] = (tor[i][26] == MN ? MN : tor[tor[i][26]][j]); } } rep(i, 19) { rep(j, n) { nx[i+1][j] = (nx[i][j] == MN ? MN : nx[i][nx[i][j]]); } } int q; cin >> q; while (q--) { int l, r; cin >> l >> r; --l; for (int i = 19; i >= 0; --i) { if (nx[i][l] < r) { l = nx[i][l]; } } puts(nx[0][l] == r ? "Yes" : "No"); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Robot and String |
User | satashun |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1164 Byte |
Status | WA |
Exec Time | 448 ms |
Memory | 93060 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 9 ms | 39168 KB |
0_01.txt | AC | 9 ms | 39168 KB |
0_02.txt | AC | 9 ms | 39168 KB |
1_00.txt | AC | 204 ms | 39424 KB |
1_01.txt | AC | 210 ms | 39424 KB |
1_02.txt | AC | 343 ms | 92932 KB |
1_03.txt | AC | 332 ms | 92932 KB |
1_04.txt | WA | 346 ms | 93060 KB |
1_05.txt | AC | 343 ms | 93060 KB |
1_06.txt | WA | 356 ms | 93060 KB |
1_07.txt | WA | 361 ms | 93060 KB |
1_08.txt | AC | 307 ms | 93060 KB |
1_09.txt | AC | 306 ms | 93060 KB |
1_10.txt | AC | 311 ms | 93060 KB |
1_11.txt | AC | 314 ms | 93060 KB |
1_12.txt | AC | 315 ms | 93060 KB |
1_13.txt | AC | 315 ms | 93060 KB |
1_14.txt | AC | 306 ms | 93060 KB |
1_15.txt | AC | 309 ms | 93060 KB |
1_16.txt | AC | 304 ms | 93060 KB |
1_17.txt | AC | 307 ms | 93060 KB |
1_18.txt | AC | 311 ms | 93060 KB |
1_19.txt | AC | 310 ms | 93060 KB |
1_20.txt | WA | 305 ms | 93060 KB |
1_21.txt | AC | 310 ms | 93060 KB |
1_22.txt | AC | 311 ms | 93060 KB |
1_23.txt | AC | 315 ms | 93060 KB |
1_24.txt | AC | 312 ms | 93060 KB |
1_25.txt | AC | 322 ms | 93060 KB |
1_26.txt | WA | 323 ms | 93060 KB |
1_27.txt | WA | 325 ms | 93060 KB |
1_28.txt | WA | 329 ms | 93060 KB |
1_29.txt | WA | 329 ms | 93060 KB |
1_30.txt | WA | 344 ms | 93060 KB |
1_31.txt | WA | 335 ms | 93060 KB |
1_32.txt | WA | 352 ms | 93060 KB |
1_33.txt | AC | 448 ms | 93060 KB |
1_34.txt | AC | 306 ms | 91524 KB |
1_35.txt | AC | 307 ms | 92420 KB |
1_36.txt | AC | 298 ms | 91140 KB |
1_37.txt | WA | 298 ms | 92292 KB |
1_38.txt | WA | 305 ms | 92932 KB |
1_39.txt | WA | 307 ms | 92932 KB |
1_40.txt | WA | 327 ms | 92420 KB |
1_41.txt | WA | 307 ms | 92932 KB |
1_42.txt | WA | 309 ms | 92036 KB |
1_43.txt | WA | 319 ms | 92932 KB |
1_44.txt | WA | 310 ms | 92932 KB |
1_45.txt | WA | 319 ms | 92676 KB |
1_46.txt | WA | 321 ms | 92804 KB |
1_47.txt | WA | 331 ms | 92292 KB |
1_48.txt | WA | 340 ms | 92932 KB |
1_49.txt | AC | 337 ms | 93060 KB |
1_50.txt | WA | 351 ms | 93060 KB |
1_51.txt | AC | 321 ms | 93060 KB |
1_52.txt | WA | 333 ms | 93060 KB |
1_53.txt | AC | 321 ms | 93060 KB |
1_54.txt | WA | 332 ms | 93060 KB |
1_55.txt | AC | 318 ms | 93060 KB |
1_56.txt | WA | 333 ms | 93060 KB |
1_57.txt | AC | 316 ms | 93060 KB |
1_58.txt | AC | 320 ms | 93060 KB |
1_59.txt | WA | 333 ms | 93060 KB |
1_60.txt | AC | 329 ms | 93060 KB |
1_61.txt | WA | 322 ms | 93060 KB |
1_62.txt | AC | 300 ms | 93060 KB |
1_63.txt | AC | 322 ms | 93060 KB |