QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#72804#4236. Triangular LogsLinshey#WA 376ms52796kbC++232.7kb2023-01-19 14:11:282023-01-19 14:11:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-19 14:11:30]
  • 评测
  • 测评结果:WA
  • 用时:376ms
  • 内存:52796kb
  • [2023-01-19 14:11:28]
  • 提交

answer


#include <bits/stdc++.h>

using namespace std; const int maxn = 1e5 + 5;

struct node { int s, ls, rs; } tr[maxn << 6]; int tt;

inline int copy(int u) { return tr[++tt] = tr[u], tt; }

int update(int u, int l, int r, int ps)
{
    u = copy(u); tr[u].s++;
    if (l == r) return u;
    int mid = l + r >> 1;
    if (ps <= mid) tr[u].ls = update(tr[u].ls, l, mid, ps); else tr[u].rs = update(tr[u].rs, mid + 1, r, ps);
    return u;
}

int sum(int u, int l, int r, int ul, int ur)
{
    if (!u) return 0;
    if (ul <= l && r <= ur) return tr[u].s;
    int mid = l + r >> 1, res = 0;
    if (ul <= mid) res += sum(tr[u].ls, l, mid, ul, ur);
    if (ur > mid) res += sum(tr[u].rs, mid + 1, r, ul, ur); return res;
}

int a[maxn], b;

void ask(int u, int v, int l, int r, int ul, int ur)
{
    if (l > ur || r < ul) return;
    if (tr[u].s == tr[v].s) return;
    if (l == r) { a[++b] = l; return; }
    int mid = l + r >> 1;
    ask(tr[u].rs, tr[v].rs, mid + 1, r, ul, ur);
    ask(tr[u].ls, tr[v].ls, l, mid, ul, ur);
}

int n, q;

int sx[maxn], sy[maxn], sz[maxn], p[maxn], rt[maxn];

unordered_map<int, int> id;

vector<pair<int, int> > ly[maxn]; int tid;

int c[maxn], d;

inline int pos(int x)
{
    int l = 0, r = n;
    while (l < r) { int mid = l + r + 1 >> 1; if (sx[p[mid]] <= x) l = mid; else r = mid - 1; }
    return l;
}

int main()
{
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) scanf("%d%d%d", sx + i, sy + i, sz + i), p[i] = i;
    sort(p + 1, p + n + 1, [](int x, int y) { return sx[x] < sx[y]; });
    for (int i = 1; i <= n; i++)
    {
        int j = (id[sy[i]] ? id[sy[i]] : (id[sy[i]] = ++tid));
        ly[j].push_back({ sx[i], sz[i] });
    }
    for (int i = 1; i <= n; i++) rt[i] = update(rt[i - 1], 1, 1000000007, sy[p[i]]);
    while (q--)
    {
        int l, u, r, d;
        scanf("%d%d%d%d", &l, &u, &r, &d);
        int L = pos(l - 1), R = pos(r);
        int s = sum(rt[R], 1, 1000000007, u, d) - sum(rt[L], 1, 1000000007, u, d);
        if (s <= 2) puts("0");
        else if (s >= 62) puts("1");
        else
        {
            b = 0;
            ask(rt[R], rt[L], 1, 1000000007, u, d);
            d = 0;
            for (int i = 1; i <= b; i++)
            {
                int j = id[a[i]];
                for (auto it = lower_bound(ly[j].begin(), ly[j].end(), make_pair(l, 0)); it != ly[j].end() && it->first <= r; it++) c[++d] = it->second;
            }
            sort(c + 1, c + d + 1);
            bool fl = 0;
            for (int i = d; i >= 3; i--) if (c[i] < c[i - 1] + c[i - 2]) { fl = 1; break; }
            puts(fl ? "1" : "0");
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 8980kb

input:

9 5
1 3 3
2 3 1
3 3 4
1 2 1
2 2 5
3 2 9
1 1 2
2 1 6
3 1 5
1 1 1 2
1 1 2 2
1 1 1 3
1 2 3 2
1 1 3 3

output:

0
1
0
0
1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 8416kb

input:

481 1
8 6788 8975
24 6552 2668
26 7948 4730
40 531 9805
110 1914 1916
164 7073 3371
165 6293 7756
170 9946 2003
179 9654 1700
215 6447 2229
221 3149 3030
242 1999 6843
242 5764 3163
249 3716 8634
250 6801 9317
260 2741 4273
282 5436 4836
284 3951 6483
288 4812 76
375 9004 5492
380 5627 5929
391 6385...

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 4ms
memory: 8816kb

input:

378 1
62730 50925 80731
92666 77280 61521
29236 67032 7889
35986 96802 8763
13313 49918 83582
51842 66775 47834
2286 12925 41106
39790 6698 15243
65145 56379 68496
35570 809 525
39834 16723 48002
77230 16273 16032
52615 7621 77300
92267 82517 39917
13170 89084 77751
45638 23868 49631
7758 71381 5191...

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 132ms
memory: 48372kb

input:

100000 100000
299999993 206450345 26023928
334281171 300000008 18107965
318653732 299999990 82338399
299999997 393028366 37212808
299999992 208114125 82126189
300000002 303613195 34463905
270033576 299999993 49200970
300000003 249755524 5829381
300000003 367329175 12867359
300000009 337452692 131045...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 124ms
memory: 48448kb

input:

100000 100000
299999990 299999990 40343876
299999990 299999991 75128878
299999990 299999992 54630219
299999990 299999993 2733654
299999990 299999994 46236519
299999990 299999995 98430004
299999990 299999996 48355189
299999990 299999997 85287882
299999990 299999998 83938086
299999990 299999999 739070...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 156ms
memory: 52796kb

input:

100000 100000
586649484 999402721 770254678
406977522 613559 332964690
987164 445493717 518079399
249557488 999424331 597100212
143514230 999205612 56986976
933588533 509797 769263555
696911 930171165 201130067
833170 541105172 912457971
145501 423684829 612968794
999276416 167526939 136454621
70428...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 205ms
memory: 52212kb

input:

100000 100000
341071 873501571 1101
59980263 526804 9
297715277 999186682 197674
709891830 999005915 346
999712634 250379232 3158
999959502 879534904 11273
253455643 999864444 49222
427866822 999577133 210191465
729566332 999548170 14
657471525 144302 846059
319542083 999756032 6275
219750473 765955...

output:

0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
...

result:

ok 100000 lines

Test #8:

score: -100
Wrong Answer
time: 376ms
memory: 50192kb

input:

100000 100000
330451877 499036874 19421
148915905 333179772 5692
556747855 500052531 51199
580265032 499999972 188350435
380806313 500000128 65
500046272 499999847 2336904
496578778 500015254 22900850
499999993 473970765 17403806
499999989 499163205 2
499999946 499999562 19056
671553596 327120722 53...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

wrong answer 42nd lines differ - expected: '1', found: '0'