QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#349195 | #6568. Space Alignment | janY# | AC ✓ | 4ms | 3772kb | C++20 | 1.9kb | 2024-03-09 23:59:31 | 2024-03-09 23:59:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
long long d, n;
cin >> n;
vector<string> c(n);
for (int i = 0; i < n; i++) {
cin >> c[i];
}
vector<int> dep(n);
int run = -1;
for (int i = 0; i < n; i++){
if (c[i].back() == '{'){
if (i == 0) run++;
else {
if (c[i-1].back() == '{') run++;
}
} else {
if (c[i-1].back() == '}'){
run--;
}
}
dep[i] = run;
}
vector<int> scnt(n);
vector<int> tcnt(n);
for (int i = 0; i < n; i++){
for (auto &z : c[i]){
if (z == 's') scnt[i]++;
if (z == 't') tcnt[i]++;
}
}
for (int i = 1; i < 1000*1000+5; i++){
int fmlt = -1;
bool isgood = true;
for (int j = 0; j < n; j++){
int thiz = scnt[j] + tcnt[j]*i;
if (dep[j] == 0){
if (thiz != 0){
isgood = false;
break;
}
} else {
if (thiz == 0){
isgood = false;
break;
}
if (fmlt == -1){
if (thiz%dep[j] == 0){
fmlt = thiz/dep[j];
} else {
isgood = false;
break;
}
} else {
if (fmlt*dep[j] != thiz){
isgood = false;
break;
}
}
}
}
if (isgood){
cout << i;
return;
}
}
cout << -1 << "\n";
}
int main(){
int t = 1;
//cin >> t;
for (int i = 0; i < t; i++) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 4ms
memory: 3528kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 4ms
memory: 3480kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 4ms
memory: 3564kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 4ms
memory: 3772kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
100 { } { } { t{ ssssssssssssssssssssssssssssssssssss} t{ t} t{ tssssssssssssssssssssssssssssssssssss{ tssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss{ tsssssssssssssssssssssssssssssssssssst} ttssssssssssssssssssssssssssssssssssss{ ssssssssssssssssssssssssssssssssssssssssss...
output:
36
result:
ok single line: '36'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
100 { t{ tssssssssssssssssssss{ ttssssssssssssssssssss{ tsssssssssssssssssssstt{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{ ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...
output:
20
result:
ok single line: '20'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
4 { t{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
999
result:
ok single line: '999'