QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706087 | #2903. Tetris Generation | vic233333# | AC ✓ | 5ms | 3708kb | C++20 | 1.8kb | 2024-11-03 06:47:44 | 2024-11-03 06:47:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
const ld pi = 3.14159265358979323846;
const int mod = 998244353;
const ll INF = 1e18;
template<typename T>
T chmax(T a, T b) {
return a > b ? a : b;
}
template<typename T>
T chmin(T a, T b) {
return a > b ? b : a;
}
const int N = (int) 1e5 + 1, M = N * 2;
const char tetrisSet[7] = {'J', 'L', 'S', 'Z', 'I', 'O', 'T'};
map<char, int> mp;
string s;
bool testMapNotPass() {
for (char j: tetrisSet) {
if (mp[j] > 1) {
return true;
}
}
return false;
}
void useMap(int left, int right) {
mp.clear();
for (int i = left; i < right; ++i) {
mp[s[i]]++;
}
}
bool solve() {
cin >> s;
for (int i = 0; i < (7 > s.length() ? s.length() : 7); ++i) {
bool flag = false;
useMap(0, i);
if (testMapNotPass()) { continue; }
int index = i;
while (index + 7 < s.length()) {
useMap(index, index + 7);
if (testMapNotPass()) {
flag = true;
break;
}
index += 7;
}
if (flag) { continue; }
useMap(index, (int) s.length());
if (testMapNotPass()) { continue; }
return true;
}
return false;
}
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
bool result = solve();
if (result) {
cout << "1" << endl;
} else {
cout << "0" << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
2 JJTO JJTT
output:
1 0
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1 O
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
2 JLSZIOTTOIZSLJ JLSZIOJLSZIOT
output:
1 1
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
7 ZSTIOILZOTSJJLIOTSZSTIZOLJSTLOJZITSIJLZOIZSJOLTTJLSZOISOIZLJTTJOSILZZITOSJLTLIZOSJSJOLTIZSOITZJLLIJSTOZOSIJTLZITLOSZJTSZILJOJZSOTLIITOLZJSZTLJISOSJLTZOIZOLISJTSILZJOTOZTJISLLZOJTSISJTILOZTIJZSOLISOZJTLITLOSZJIZJOTSLTSZILJOTIJLZOSTLZOJSIOSJTLZISZLJTIOITLOSZJSOIJZLTLJSTOIZSOZJITLLISJOTZTJOILSZLTJZIS...
output:
1 1 1 1 1 1 1
result:
ok 7 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 ZSTIOILZOTSJJLIOTSZSTIZOLJSTLOJZITSIJLZOIZSJOLTOJLSZOISOIZLJTTJOSILZZITOSJLTLIZOSJSJOLTIZSOITZJLLIJSTOZOSIJTLZITLOSZJTSZILJOJZSOTLIITOLZJSZTLJISOSJLTZOIZOLISJTSILZJOTOZTJISLLZOJTSISJTILOZTIJZSOLISOZJTLITLOSZJIZJOTSLTSZILJOTIJLZOSTLZOJSIOSJTLZISZLJTIOITLOSZJSOIJZLTLJSTOIZSOZJITLLISJOTZTJOILSZLTJZIS...
output:
0 1 0
result:
ok 3 lines
Test #6:
score: 0
Accepted
time: 5ms
memory: 3708kb
input:
100 TOISIZOLSJTLZTOSIJLTZSJOILOSTZJIOLJZTISZIOLTJSJZLTOISLTOIZJSZLITOSJSTZJOILOSLZITJOJTIZLSSOITJZLLOTJISZZSITJLOZTLJISOIOTSLJZZOTISLJLISOTJZLZJSOITZSIJLTOLSJIOTZJTOZSLILJTIOZSLOZTSJITJZIOLSLOSTJIZSLOJTZIZSOIJTLIOTJZSLIZJOLSTSJLITOZSJITZOLJLTZSOIIJOTZLSIZOSTJLISOJTZLLOIJSZTZILSO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