QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90536#5251. ConstellationsSolitaryDream#WA 1ms9808kbC++201.6kb2023-03-23 15:23:592023-03-23 15:24:01

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
const int N = 2e5 + 10;
int n, m, ans[N];
vector<pii> que[N];
struct Point {
    int x, y;
};
Point p[N];
Point operator+(Point u, Point v) { return {u.x + v.x, u.y + v.y}; }
Point operator-(Point u, Point v) { return {u.x - v.x, u.y - v.y}; }
int Det(Point u, Point v) { return u.x * v.y - u.y * v.x; }
signed main() {
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &p[i].y);
        p[i].y += p[i - 1].y;
        p[i].x = i;
    }
    for (int i = 1, x, y; i <= m; ++i) {
        scanf("%lld%lld", &x, &y);
        que[x - 1].push_back(pii(x + y - 1, i));
    }
    vector<int> conv;
    for (int i = n; ~i; --i) {
        static vector<int> sp; sp.clear();
        while (conv.size() >= 2 && Det(p[conv.size() - 2] - p[i], p[conv.size() - 1] - p[i]) <= 0) {
            sp.push_back(conv.back());
            conv.pop_back();
        }
        if (conv.size()) sp.push_back(conv.back());
        conv.push_back(i);
        sort(que[i].begin(), que[i].end());
        int pt = 0;
        for (auto [y, id] : que[i]) {
            while (pt + 1 < (int)sp.size() && sp[pt] <= y) ++pt;
            Point delta = p[sp[pt]] - p[i];
            printf("[%lld %lld] : %lld %lld\n", i + 1, y, delta.y, delta.x);
            if (delta.y < 0) ans[id] = -1;
            else ans[id] = delta.y / delta.x;
        }
    }
    for (int i = 1; i <= m; ++i) {
        if (ans[i] < 0) puts("stay with parents");
        else printf("%lld\n", ans[i]);
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9808kb

input:

2
0 0
1 0

output:


result:

wrong answer 1st lines differ - expected: '2', found: ''