QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#359330 | #6568. Space Alignment | nkamzabek# | WA | 0ms | 3808kb | C++23 | 1.2kb | 2024-03-20 16:34:15 | 2024-03-20 16:34:15 |
Judging History
answer
#include <bits/stdc++.h>
#define f first
#define s second
#define sz(s) (int)s.size()
#define int long long
using namespace std;
const int N = (int)5e5 + 100;
const int M = N + 7;
const int MOD = 998244353;
const int INF = (int)1e18 + 100;
int n, cnt[N][2];
main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
int bal = 0;
set<int> u;
for(int i = 1; i <= n; i++){
string s;
cin >> s;
int d = 1;
for(auto x : s){
if(x == 's')
cnt[i][0]++;
if(x == 't')
cnt[i][1]++;
if(x == '{')
d = 1;
else
d = -1;
}
if(d == -1) bal += d;
if(cnt[i][0] || cnt[i][1]){
int delta = bal - cnt[i][1];
if(delta){
int c = cnt[i][0] / (bal - cnt[i][1]);
if(cnt[i][0] % c || cnt[i][0] < c){
cout << "-1\n";
return 0;
}
u.insert(c);
}
}
if(d == 1) bal += d;
}
if(u.size() != 1) cout << "-1\n";
else{
cout << *u.begin() << "\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'