QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93862#6192. Interval Problemwhatever#WA 48ms15836kbC++171.4kb2023-04-03 14:06:302023-04-03 14:06:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 14:06:31]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:15836kb
  • [2023-04-03 14:06:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
template<typename T> void up(T &x, T y) { if (x < y) x = y; }
template<typename T> void down(T &x, T y) { if (x > y) x = y; }

int n, l[200005], r[200005], sum[400005], lp[400005], g[400005], h[400005];
i64 f[400005], ans[200005];

void solve() {
    memset(sum, 0, sizeof sum);
    memset(lp, 0x3f, sizeof lp);
    rep(i, 1, n) ++sum[r[i]], down(lp[r[i]], l[i]);
    rep(i, 1, 2 * n) sum[i] += sum[i - 1];
    per(i, 2 * n, 1) down(lp[i], lp[i + 1]);

    rep(i, 1, 2 * n) {
        if (lp[i] > n) break;
        if (lp[i] >= i) {
            g[i] = i;
            f[i] = h[i] = 0;
        } else {
            g[i] = g[lp[i]];
            f[i] = f[lp[i]] + sum[i - 1];
            h[i] = h[lp[i]] + 1;
        }
    }

    rep(i, 1, n) {
        int x = l[i], y = g[x];
        ans[i] += f[x];
        ans[i] -= 1ll * sum[y - 1] * (h[x] + 1);
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n;
    rep(i, 1, n) cin >> l[i] >> r[i], ans[i] = n - 1;

    solve();
    rep(i, 1, n) {
        l[i] = 2 * n - l[i] + 1;
        r[i] = 2 * n - r[i] + 1;
        swap(l[i], r[i]);
    }
    solve();

    rep(i, 1, n) cout << ans[i] << "\n";

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 13616kb

input:

5
2 3
6 7
1 9
5 10
4 8

output:

7
5
4
5
5

result:

ok 5 number(s): "7 5 4 5 5"

Test #2:

score: -100
Wrong Answer
time: 48ms
memory: 15836kb

input:

200000
342504 342505
248314 248317
259328 259334
234817 234821
225726 225732
371424 371425
260562 260565
34752 34753
132098 132100
262130 262134
7254 7255
228491 228492
43488 43492
188408 188410
11691 11692
350334 350335
327350 327352
360684 360685
182051 182052
72131 72135
194666 194668
61303 61313...

output:

171257
124160
129666
117414
112878
185712
130282
182624
133951
131083
196373
114245
178260
105798
194155
175169
163676
180357
108983
163934
102667
169354
131747
158663
178270
143839
107935
155860
190334
127188
187915
111124
100894
167731
196274
191027
173545
187472
181665
114876
100931
116409
113644...

result:

wrong answer 1st numbers differ - expected: '12', found: '171257'