QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207749 | #6568. Space Alignment | Freeuni1# | WA | 0ms | 7572kb | C++23 | 1.2kb | 2023-10-08 19:51:32 | 2023-10-08 19:51:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define ARRS ((ll)(2e6 + 100))
#define MOD ((ll)998244353)
#define MAX ((ll)(1e9 + 100))
#define EP ((double)(1e-9))
ll cs[ARRS];
ll ct[ARRS];
ll dir[ARRS];
int main() {
ll n;
cin>>n;
for(int i=0; i<n; i++){
string s;
cin>>s;
for(int j=0; j<s.size(); j++){
if(s[j]=='s')cs[i]++;
if(s[j]=='t')ct[i]++;
}
if(s[s.size()-1]=='{') dir[i]=1;
else dir[i]=-1;
}
for(int wt=1; wt<=1; wt++){
ll ws = -1;
ll cd = 0;
ll good=1;
for(int i=0; i<n; i++){
if(dir[i]==-1)cd--;
ll d = cd;
// cout<<cd<<endl;
if(!d&&(ct[i]+cs[i])>0) {
good=0;
break;
}
if(ct[i]%wt!=0){
good=0;
break;
}
d-=ct[i]/wt;
if(!d&&cs[i]>0) {
good=0;
break;
}
if(d && ws==-1){
if(cs[i]%d!=0){
good=0;
break;
}
ws = cs[i]/d;
}
if(cs[i]%ws){
good=0;
break;
}
d-=cs[i]/ws;
if(d!=0) {
good=0;
break;
}
if(dir[i]==1)cd++;
}
// cout<<"g"<<good<<endl;
if(good){
if(ws%wt==0){
cout<<ws/wt<<endl;
return 0;
}
}
}
cout<<-1<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7572kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3484kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'