QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114099 | #6568. Space Alignment | UFRJ# | WA | 1ms | 3536kb | C++20 | 1.4kb | 2023-06-20 23:01:07 | 2023-06-20 23:01:09 |
Judging History
answer
#include "bits/stdc++.h"
using lint = int64_t;
using ld = long double;
using namespace std;
const lint inf = lint(1e18) + 1;
int n;
struct Line
{
int d, s, t;
};
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int d = 0;
cin >> n;
vector<Line> v;
for(int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
if(tmp.back() == '}') d--;
int cntS = 0, cntT = 0;
for(auto &i : tmp) {
if(i == 's') cntS++;
if(i == 't') cntT++;
}
if(d != 0 and (cntS + cntT) > 0) v.push_back({d, cntS, cntT});
if(tmp.back() == '{') d++;
}
// for(auto &i : v) {
// cout << i.d << " = " << i.s << " + " << i.t << endl;
// }
lint ans = inf;
for(int i = 0; i < v.size(); i++) {
ld si = (ld) v[i].s/v[i].d;
ld ti = (ld) v[i].t/v[i].d;
set<lint> possible;
for(int j = 0; j < v.size(); j++) {
if(j == i) continue;
ld ns = si*v[j].d;
ld nt = ti*v[j].d;
long double ps = (ns - v[j].s)/(v[j].t - nt);
if(ps > 0) possible.insert(ps);
// cout << ps << endl;
}
// cout << "Possible: " << i << "\n";
// for(auto &i : possible) cout << i << ' ';
// cout << endl;
if(possible.size() > 0) {
ans = min(ans, *possible.begin());
}
}
if(ans == inf) cout << -1 << endl;
else cout << ans << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3536kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3496kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'