QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706518 | #6568. Space Alignment | ucup-team902# | WA | 0ms | 3640kb | C++17 | 1.5kb | 2024-11-03 11:56:45 | 2024-11-03 11:56:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
cs int N=1005;
vector<pii> p[N];
int n;
int main(){
#ifdef Stargazer
freopen("1.in","r",stdin);
#endif
cin>>n;
int dep=0;
for(int j=1;j<=n;j++){
string x;cin>>x;
pii y;
for(int l=x.length(),i=0;i<l;i++){
if(x[i]=='s')y.se++;
if(x[i]=='t')y.fi++;
if(x[i]=='{'){
p[dep].pb(y);
// cout<<j<<" "<<dep<<'\n';
dep++;
}
if(x[i]=='}'){
dep--;
p[dep].pb(y);
// cout<<j<<" "<<dep<<'\n';
}
}
}
int ans=-1;
for(int i=0;i<=n;i++)if(p[i].size()){
//cout<<i<<'\n';
//for(pii x:p[i])cout<<x.fi<<" "<<x.se<<'\n';
for(int j=0;j<p[i].size();j++)
for(int k=j+1;k<p[i].size();k++){
pii x=p[i][j],y=p[i][k];
if(x.fi!=y.fi){
int res=(y.se-x.se)/(x.fi-y.fi);
if(res<0){
puts("-1");return 0;
}
if(ans>=0&&ans!=res){
puts("-1");return 0;
}
ans=res;
}
else{
if(x.se!=y.se){
puts("-1");return 0;
}
}
}
}
if(ans>=0)cout<<ans<<'\n';
else cout<<0<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
2 { }
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'