QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114098 | #6568. Space Alignment | UFRJ# | WA | 1ms | 3496kb | C++20 | 1.3kb | 2023-06-20 22:59:48 | 2023-06-20 22:59:49 |
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());
}
}
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3472kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3496kb
input:
2 { }
output:
1000000000000000001
result:
wrong answer 1st lines differ - expected: '1', found: '1000000000000000001'