QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111010 | #6568. Space Alignment | Tobo# | WA | 3ms | 3468kb | C++20 | 1.5kb | 2023-06-05 13:45:08 | 2023-06-05 13:45:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define N 200005
void solve()
{
int n;
cin >> n;
vector<array<int, 3>> a(n + 1);
for (int i = 1; i <= n; i++)
{
string ss;
cin >> ss;
int s = 0, t = 0, z = 0;
for (char c : ss)
{
if (c == 's')
s++;
else if (c == 't')
t++;
else if (c == '{')
z++;
else
z--;
}
a[i] = {s, t, z};
}
for (int j = 1; j <= 1e6; j++)
{
bool is = 1;
int tab = -1, cnt = 0;
for (int i = 1; i <= n; i++)
{
auto [s, t, o] = a[i];
if (o == -1)
cnt -= j;
int z = cnt;
if (s > z || (t > 0 && (z - s) % t))
{
is = 0;
break;
}
if (t > 0)
{
if (tab == -1)
tab = (z - s) / t;
else if (tab != (z - s) / t)
{
is = 0;
break;
}
}
if (o == 1)
cnt += j;
}
if (is)
{
cout << tab << '\n';
return;
}
}
cout << -1;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3464kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3468kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'