QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754611 | #2902. Shortest Missing Subsequences | i24 | AC ✓ | 239ms | 247812kb | C++14 | 1.3kb | 2024-11-16 15:23:51 | 2024-11-16 15:23:59 |
Judging History
answer
// File generated on 24/11/15 22:03 by Anand
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(0)
#define rep(i, m, n) for (long long i = m; i < n; i++)
#define DEBUG(x) cout << "debug: " << x << "\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define pb push_back
#define sz size
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vec;
typedef vector<vec> vecc;
typedef vector<pll> vecp;
void SOLVE() {
set<char> a;
string u;
cin >> u;
string s;
cin >> s;
vector<vector<ll>> q(s.size() + 1, vector<ll>(26, -1));
for(ll i = s.size() - 1; i >= 0; --i) {
for(int j = 0; j < 26; j++) {
if (s[i] == 'a' + j) {q[i][j] = i + 1;}
else q[i][j] = q[i+1][j];
}
}
ll ans = 0;
for(char& i : s) {
a.insert(i);
if (a.size() == u.size()) {ans++; a.clear();}
}
ans++;
ll n;
cin >> n;
while(n--) {
string g;
cin >> g;
if (g.size() != ans) {cout << "0\n"; continue;}
ll cur = 0;
for(char& i : g) {
cur = q[cur][i - 'a'];
if (cur == -1) break;
}
if (cur == -1) cout << "1\n";
else cout << "0\n";
}
}
signed main() {
fastio;
SOLVE();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
abcd abcccabac 3 cbb cbba cba
output:
0 0 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
z zzzzzzz 10 z zz zzz zzzz zzzzz zzzzzz zzzzzzz zzzzzzzz zzzzzzzzz zzzzzzzzzz
output:
0 0 0 0 0 0 0 1 0 0
result:
ok 10 lines
Test #3:
score: 0
Accepted
time: 239ms
memory: 246308kb
input:
abcdefghijklmnopqrstuvwxyz oaxsgfhkwuecvdrltjzpqibnymtaympfvuzogrqkwhbdcsjleixnojmletqrbkdzfhawpsxcvyniughnqibtzjpewovluyrdfmakxscgcyhmqbieontgwufalzjsprvkdxzfqsrijldncaphwxyutbgevmokltvqhkprunydecwmgxoijzbfsacafhozxyljvnrmbdupeqiswgtkbhwxptqayglfovirnjuemkdczsmyadiqnwtxjbhlsvokpucgefrzvicbdnkrjmxgf...
output:
0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
result:
ok 26 lines
Test #4:
score: 0
Accepted
time: 147ms
memory: 247812kb
input:
d dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 96ms
memory: 246316kb
input:
abcdefghijklmnopqrstuvwxyz wktxlbgnmkyuvhmjpxxfndhdtcqugxnsvpxdictbxwrimocjliqqxfomlwngbvyoyacswksvurqaqmvwigtiswbfyofgvdvolcciwnymchohsdoivyofupophlcpukipgheeveaqrgmbcrtdwdybwcxsyvorkvsnhnvgwfxrpvykphlmrqsyujciqdmpqiwegathdsfjueilvbcudwsfbvpqxyoprbadqepvpdkcjvdapafesdmftubyraolqcvgbfbqhjlebnmbpcskf...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 ...
result:
ok 10000 lines
Test #6:
score: 0
Accepted
time: 106ms
memory: 246312kb
input:
abcdefghijklmnopqrstuvwxyz wktxlbgnmkyuvhmjpxxfndhdtcqugxnsvpxdictbxwrimocjliqqxfomlwngbvyoyacswksvurqaqmvwigtiswbfyofgvdvolcciwnymchohsdoivyofupophlcpukipgheeveaqrgmbcrtdwdybwcxsyvorkvsnhnvgwfxrpvykphlmrqsyujciqdmpqiwegathdsfjueilvbcudwsfbvpqxyoprbadqepvpdkcjvdapafesdmftubyraolqcvgbfbqhjlebnmbpcskf...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 ...
result:
ok 10000 lines
Test #7:
score: 0
Accepted
time: 125ms
memory: 246240kb
input:
abcdefghijklmnopqrstuvwxyz ngmgaeihgmnehfjdicecmbjmeilmjceblbnkfhibfgfjkdihhnieamiablnglnmkkajhnnfdlflnbdjddmcmihbbfihbeielbifnidmjijehbjmgfjdecdncajkehbbkmccanblnikgnlieimdndkjngjehhkklmfbfjbhjkfnddalebldfmcfgnabmcnldanjkijkbabkdjnjbgbfnbajadclbhdlmakaigjbnebdbkefgcaihajblgdeflhnjclkdmamkcncfiebjhk...
output:
1 0 1 1 1 0 1 0 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 1 1 1 0 0 0 1 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 1 0 1 0 ...
result:
ok 1000000 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
abcd aabcdacbacdabcabdcccbddadbcdbacbdad 8 dddaadda dddaaddb dddaaddc dddaaddd dddaadaa dddaadab dddaadac dddaadad
output:
0 0 0 0 0 0 0 0
result:
ok 8 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
f f 2 f ff
output:
0 1
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
xy x 6 x y xx xy yx yy
output:
0 1 0 0 0 0
result:
ok 6 lines
Test #11:
score: 0
Accepted
time: 111ms
memory: 246172kb
input:
abcdefghijklmnopqrstuvwxyz irxwwhliqvpptnwkhqgyxopsvwguplvwksziymgggtrgzynukovgrkwpzqrknkukvpzmzgoxzrztijtvymivmyvuqzoqxzujmlsyqxzqosxgqlvwootjnryuwuvnhptqiwjqxonqvgpgmuxsssotjjqkgwkrzyrkoqnzxsnpzltrsvgowxxyzvqwiqwrkozhqynrrkzqoqxnongrrtwsmpsgwktjrsjyhwrwxxzlgxzuhhygpgvvllliwtjnmhjjlrzjtltumpumqpigm...
output:
0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ...
result:
ok 200000 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
abcdefghijklmnopqrstu orslbpmouunpnnfcgtbplsqimmroonbfbgoehmkohbdekngpkkudgpeknramojnffimsborgoheggfshaqrhteepcmchqdtsu 1 au
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
ab aab 1 bb
output:
1
result:
ok single line: '1'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
ab ba 1 bb
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
abc baaaaac 1 cc
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
abc abcccabac 3 cbb cbba cba
output:
1 0 0
result:
ok 3 lines