QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#642348 | #6568. Space Alignment | enze114514 | WA | 0ms | 3616kb | C++20 | 1.4kb | 2024-10-15 13:21:18 | 2024-10-15 13:21:24 |
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)2e5 + 1, M = N * 2;
void solve(){
int n;
cin >> n;
vector<vector<int>> a;
for(int i = 0; i < n; i++){
string s;
cin >> s;
int S = 0, T = 0;
for(int i = 0; i < s.size() - 1; i++){
if(s[i] == 's') S++;
else T++;
}
a.pb({(s.back() == '{' ? 0 : 1), S, T});
}
for(int i = 1; i <= 1000; i++){
stack<int> stk;
for(int j = 0; j < a.size(); j++){
if(!stk.empty() && !a[stk.top()][0] && a[j][1] && a[stk.top()][1] + a[stk.top()][2] * i == a[j][1] + a[j][2] * i){
stk.pop();
}
else{
stk.push(j);
}
}
if(stk.empty()){
cout << i << endl;
return;
}
}
cout << -1 << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
-1
result:
wrong answer 1st lines differ - expected: '2', found: '-1'