QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114099#6568. Space AlignmentUFRJ#WA 1ms3536kbC++201.4kb2023-06-20 23:01:072023-06-20 23:01:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-20 23:01:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2023-06-20 23:01:07]
  • 提交

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'