QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570063 | #2903. Tetris Generation | JustJie | AC ✓ | 1ms | 3824kb | C++20 | 1.5kb | 2024-09-17 13:38:15 | 2024-09-17 13:38:16 |
Judging History
answer
/***************************************************************************************************
* author : Jie Chen (4th Year CS)
* school : Rochester Institute of Technology
* created: 09.17.2024 01:30:42
****************************************************************************************************/
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
int ord(char c) { return c - 'a'; }
void work(int tc) {
string s;
cin >> s;
int n = s.size();
const auto has = [&](int mask, int nth) {
return mask & (1 << nth);
};
const auto good = [&](int start) {
for (int i = start; i < n; i += 7) {
int mask = 0;
for (int j = i; j < min(n, i + 7); j++) {
int o = s[j];
if (has(mask, o)) {
return false;
}
mask |= (1 << o);
}
}
return true;
};
int seen = 0;
for (int i = 0; i < min(n, 7); i++) {
int o = ord(s[i]);
if (!has(seen, o)) {
seen |= (1 << o);
if (good(i + 1)) {
cout << "1\n";
return;
}
} else {
break;
}
}
cout << "0\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
for (int t = 1; T--; t++) {
work(t);
}
}
// ~ JustJie
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
2 JJTO JJTT
output:
1 0
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 O
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 JLSZIOTTOIZSLJ JLSZIOJLSZIOT
output:
1 1
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
7 ZSTIOILZOTSJJLIOTSZSTIZOLJSTLOJZITSIJLZOIZSJOLTTJLSZOISOIZLJTTJOSILZZITOSJLTLIZOSJSJOLTIZSOITZJLLIJSTOZOSIJTLZITLOSZJTSZILJOJZSOTLIITOLZJSZTLJISOSJLTZOIZOLISJTSILZJOTOZTJISLLZOJTSISJTILOZTIJZSOLISOZJTLITLOSZJIZJOTSLTSZILJOTIJLZOSTLZOJSIOSJTLZISZLJTIOITLOSZJSOIJZLTLJSTOIZSOZJITLLISJOTZTJOILSZLTJZIS...
output:
1 1 1 1 1 1 1
result:
ok 7 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
3 ZSTIOILZOTSJJLIOTSZSTIZOLJSTLOJZITSIJLZOIZSJOLTOJLSZOISOIZLJTTJOSILZZITOSJLTLIZOSJSJOLTIZSOITZJLLIJSTOZOSIJTLZITLOSZJTSZILJOJZSOTLIITOLZJSZTLJISOSJLTZOIZOLISJTSILZJOTOZTJISLLZOJTSISJTILOZTIJZSOLISOZJTLITLOSZJIZJOTSLTSZILJOTIJLZOSTLZOJSIOSJTLZISZLJTIOITLOSZJSOIJZLTLJSTOIZSOZJITLLISJOTZTJOILSZLTJZIS...
output:
0 1 0
result:
ok 3 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
100 TOISIZOLSJTLZTOSIJLTZSJOILOSTZJIOLJZTISZIOLTJSJZLTOISLTOIZJSZLITOSJSTZJOILOSLZITJOJTIZLSSOITJZLLOTJISZZSITJLOZTLJISOIOTSLJZZOTISLJLISOTJZLZJSOITZSIJLTOLSJIOTZJTOZSLILJTIOZSLOZTSJITJZIOLSLOSTJIZSLOJTZIZSOIJTLIOTJZSLIZJOLSTSJLITOZSJITZOLJLTZSOIIJOTZLSIZOSTJLISOJTZLLOIJSZTZILSOJTOZILSTJTOLSZIJSOZJI...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1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