QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#415596 | #6568. Space Alignment | ngpin04# | WA | 0ms | 3636kb | C++14 | 1.6kb | 2024-05-21 03:57:27 | 2024-05-21 03:57:27 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define bit(n) (1LL << (n))
#define getbit(x, i) (((x) >> (i)) & 1)
#define ii pair <int, int>
#define ALL(x) x.begin(), x.end()
#define long long long
using namespace std;
const int oo = 1e9;
const long ooo = 1e18;
vector<ii> vec[501];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int depth = 0;
for(int i = 0; i < n; i++)
{
int s = 0;
int t = 0;
string str; cin >> str;
for(char c : str)
{
s += (c == 's');
t += (c == 't');
}
if(str.back() == '}') depth--;
vec[depth].push_back({s,t});
if(str.back() == '{') depth++;
}
for(int i = 0; i <= 2000; i++)
{
bool bol = 1;
for(auto it : vec[0])
{
int val = it.fi+it.se*i;
// cout << "0 " << val << '\n';
if(val) bol = 0;
}
if(!bol) continue;
set<int> st;
for(int j = 1; j <= 100; j++)
{
for(auto it : vec[j])
{
int val = it.fi+it.se*i;
// cout << i << " " << j << " " << val << '\n';
if(val%j != 0) bol = 0;
st.insert(val/j);
}
}
if(!bol) continue;
if(st.size() <= 1)
{
cout << i << "\n";
return 0;
}
}
cout << "-1\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
input:
2 { }
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'