QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#153164 | #6568. Space Alignment | qzez# | WA | 1ms | 3528kb | C++14 | 1.2kb | 2023-08-29 15:14:14 | 2023-08-29 15:14:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
cerr<<x<<' ',debug(y...);
}
const int N=1e2+10,M=1e3+10;
int n;
vector<tuple<int,int,int> >o;
char s[M];
bool chk(int ans){
int t1,t2,dep;
tie(t1,t2,dep)=o[1];
int tmp=t1+t2*ans;
for(auto t:o){
int t1,t2,dep;
tie(t1,t2,dep)=t;
if(t1+t2*ans!=1ll*dep*tmp)return 0;
}
return 1;
}
int main(){
scanf("%d",&n);
if(n==2)return cout<<0<<endl,0;
for(int i=1,x=0;i<=n;i++){
scanf("%s",s+1);
int len=strlen(s+1);
int t1=0,t2=0;
for(int j=1;j<len;j++){
t1+=s[j]=='s',t2+=s[j]=='t';
}
if(s[len]=='}')x--;
// debug(t1,t2,x);
o.push_back({t1,t2,x});
if(s[len]=='{')x++;
}
for(int ans=1;ans<=10000;ans++){
if(chk(ans))return cout<<ans<<endl,0;
}
cout<<-1<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3428kb
input:
2 { }
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'