QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#663261#8705. 圣遗物peaneval_kala0 205ms5960kbC++2310.4kb2024-10-21 14:28:052024-10-21 14:28:07

Judging History

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

  • [2024-10-21 14:28:07]
  • 评测
  • 测评结果:0
  • 用时:205ms
  • 内存:5960kb
  • [2024-10-21 14:28:05]
  • 提交

answer

#pragma GCC optimize(3, "unroll-loops", "no-stack-protector")
#define atsum(l, r) accumulate(l, r, 0)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 0x3f3f3f3f;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
inline void chkmin(T &x, T y) { x = min(x, y); }
template <typename T>
inline void chkmax(T &x, T y) { x = max(x, y); }
namespace FastIO
{
// ------------------------------
#define IN_HAS_NEG
#define OUT_HAS_NEG
#define CHK_EOF
#define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined (_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
    inline char gc() { return getchar(); }
    inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
    INLINE_V constexpr int _READ_SIZE = 1 << 18;
    INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
    inline char gc()
    {
        if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
        {
            _read_ptr = _read_buffer;
            _read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
            if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
        }
        return *_read_ptr++;
    }
#else
    INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
    inline char gc() { return *_read_ptr++; }
#endif
    INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
    INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
    inline void pc(char c)
    {
        *_write_ptr++ = c;
        if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
        {
            fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
            _write_ptr = _write_buffer;
        }
    }
    INLINE_V struct _auto_flush
    {
        ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
    }	_auto_flush;
#endif
#ifdef CHK_EOF
    inline bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
    inline bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
    inline bool _isdigit(char c) { return c & 16; }
    inline bool _isgraph(char c) { return c > 32; }
#endif
    template < class T >
    INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
    template < class T >
    INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
    template < class T >
    INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
    template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
    template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
    template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
    template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
    inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
    inline void read_cstr(char *s)
    {
        char c = gc(); while ( !_isgraph(c) ) c = gc();
        while ( _isgraph(c) ) *s++ = c, c = gc();
        *s = 0;
    }
    inline void read(string &s)
    {
        char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
        while ( _isgraph(c) ) s.push_back(c), c = gc();
    }
#ifdef IN_HAS_NEG
    template < class T, enable_if_t < _is_signed < T >, int > = 0 >
    inline void read(T &x)
    {
        char c = gc(); bool f = true; x = 0;
        while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
        if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
        else     while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
    }
    template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
    template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
    inline void read(T &x)
    {
        char c = gc(); while ( !_isdigit(c) ) c = gc();
        x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
    }
    inline void write(char c) { pc(c); }
    inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
    inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
    template < class T, enable_if_t < _is_signed < T >, int > = 0 >
    inline void write(T x)
    {
        char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
        if ( x >= 0 )  do buffer[digits++] =  ( x % 10 ) | 48, x /= 10; while ( x );
        else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
        while ( digits ) pc(buffer[--digits]);
    }
    template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
    template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
    inline void write(T x)
    {
        char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
        do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
        while ( digits ) pc(buffer[--digits]);
    }
    template < int N > struct _tuple_io_helper
    {
        template < class ...T >
        static inline void _read(tuple < T... > &x)
        { _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
        template < class ...T >
        static inline void _write(const tuple < T... > &x)
        { _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
    };
    template <> struct _tuple_io_helper < 1 >
    {
        template < class ...T >
        static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
        template < class ...T >
        static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
    };
    template < class ...T >
    inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
    template < class ...T >
    inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
    template < class T1, class T2 >
    inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
    template < class T1, class T2 >
    inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
    template < class T1, class ...T2 >
    inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
    template < class ...T >
    inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
    template < class T1, class ...T2 >
    inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
    template < class ...T >
    inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
    template < class T >
    inline void print(const T &x) { write(x); }
    inline void print_cstr(const char *x) { write_cstr(x); }
    template < class T1, class ...T2 >
    inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
    template < class ...T >
    inline void print_cstr(const char *x, const T *...y) { print_cstr(x), pc(32), print_cstr(y...); }
    inline void println() { pc(10); }
    inline void println_cstr() { pc(10); }
    template < class ...T >
    inline void println(const T &...x) { print(x...), pc(10); }
    template < class ...T >
    inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;
template <typename T>
inline void clear(T &x) {
    T y;
    swap(x, y);
}
using ld = long double;
const int N = 50005;
struct Node {
    ld x, y;
    int idx, idy;
};
vector<Node> g, f;
int L;
int a[N];
inline ld calc(Node a, Node b, ld c) {
    return (b.y - a.y) / (b.x - a.x) * (c - a.x) + a.y;
}
inline vector<Node> solve(vector<Node> qaq) {
    sort(qaq.begin(), qaq.end(), [&](Node x, Node y) { return x.x != y.x ? x.x < y.x : x.y < y.y; });
    vector<Node> res;
    for (int i = 0; i < qaq.size(); i++) {
        if (i + 1 != qaq.size() && qaq[i].x == qaq[i + 1].x) continue;
        while (res.size() >= 2 && calc(res.end()[-2], qaq[i], res.back().x) >= res.back().y) res.pop_back();
        res.push_back(qaq[i]);
    }
    return res;
}
int ans[N], pans[N], tans[N];
inline void work() {
    clear(f), clear(g);
    // read(L);
    cin >> L;
    ld jia = 0, jib = 0;
    for (int i = 1; i <= L; i++) {
        clear(f);
        int n1;
        cin >> n1;
        for (int p = 1; p <= n1; p++) {
            ld pa, pb;
            cin >> pa >> pb;
            f.push_back({pa, pb, i, p});
        }
        f = solve(f);
        jia += f[0].x, jib += f[1].y;
        pans[i] = f[0].idy;
        int psiz = g.size();
        for (int j = 1; j < f.size(); j++) g.push_back({f[j].x - f[j - 1].x,  f[j].y - f[j - 1].y, f[j].idx, f[j].idy});
        assert(is_sorted(g.begin() + psiz, g.end(), [&](Node a, Node b) { return a.y / a.x > b.y / b.x; }));
    }
    sort(g.begin(), g.end(), [&](Node a, Node b) { return a.y / a.x > b.y / b.x; });
    int q;
    // cerr << "find pans:" << pans[1] << ' ' << pans[2] << endl;
    // for (auto [px, py, fwa, fwb] : g) cerr << "find youmo:" << px << ' ' << py << ' ' << fwa << ' ' << fwb << endl;
    cin >> q;
    while (q--) {
        ld Xa, Xb;
        cin >> Xa >> Xb;
        ld valans = 0;
        ld pjia = jia, pjib = jib;
        chkmax(valans, (Xa + pjia) * (Xb + pjib));
        for (auto [px, py, fwa, fwb] : g) pjia += px, pjib += py, chkmax(valans, (Xa + pjia) * (Xb + pjib));
        pjia = jia, pjib = jib;
        memcpy(ans, pans, sizeof(ans[0]) * (L + 2));
        memcpy(tans, pans, sizeof(ans[0]) * (L + 2));
        for (auto [px, py, fwa, fwb] : g) {
            // cerr << "find update:" << fwa << ' ' << fwb << endl;
            pjia += px, pjib += py;
            ans[fwa] = fwb;
            if ((Xa + pjia) * (Xb + pjib) == valans) {
                memcpy(tans, ans, sizeof(ans[0]) * (L + 2));
                break;
            }
        }
        // cerr << "find ans:" << valans << endl;
        for (int i =1; i <= L; i++) cout << tans[i] << ' ';
        cout << endl;
    }
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int T;
    cin >> T >> T;
    while (T--) work();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3848kb

input:

1 100
5
3
98 71 28 7 62 13
3
29 23 65 70 34 95
3
59 41 64 43 92 59
3
73 75 99 96 43 2
3
14 24 5 7 54 13
10
8.06 47.73
183.28 351.90
83.70 90.40
34.00 127.83
216.88 312.31
182.09 349.61
266.90 320.28
84.18 420.91
33.26 145.00
118.07 354.22
5
3
25 63 11 75 63 31
3
94 53 38 89 46 23
3
49 99 12 80 52 4
...

output:

1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
1 2 3 2 3 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
3 1 1 2 1 
1 3 1 1 2 
1 3 1 1 2 
1 3 1 1 2 
1 2 1 1 2 
1 3 1 1 2 
1 3 1 1 2 
1 3 1 1 2 
1 3...

result:

wrong answer Test case #3, Query #6, Your answer is not good enough

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 9ms
memory: 3988kb

input:

2 100
27
9
58 21 76 52 99 40 22 25 26 38 25 65 80 47 59 83 12 7
10
87 40 54 90 65 88 86 75 92 22 5 70 53 88 72 34 25 55 7 66
10
8 69 28 19 80 41 17 15 40 82 9 57 77 43 79 63 24 39 62 30
10
38 41 5 45 55 80 93 63 96 46 98 50 31 48 49 49 77 63 46 54
10
99 11 33 21 69 25 9 17 93 30 87 16 22 93 97 36 84...

output:

3 4 8 4 10 10 6 10 6 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 10 2 
3 4 8 4 10 10 6 10 6 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 5 2 
3 4 8 4 10 10 7 10 3 7 10 6 8 1 10 4 4 5 4 5 3 3 7 7 9 5 2 
3 4 8 4 10 10 7 10 3 7 10 6 8 1 10 4 4 5 4 5 3 3 7 7 9 5 2 
3 4 8 4 10 10 6 10 3 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 5 2 ...

result:

wrong answer Test case #1, Query #1, Your answer is not good enough

Subtask #3:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 157ms
memory: 3944kb

input:

3 100
496
9
62 33 67 95 25 42 68 17 2 18 65 76 39 78 27 37 55 75
9
97 77 28 91 37 55 83 37 34 82 12 29 58 78 28 6 81 35
8
17 22 2 52 92 14 4 59 82 7 23 37 75 67 39 87
8
62 70 17 5 7 95 84 73 36 35 17 85 84 61 89 69
9
1 80 10 60 37 75 51 64 42 24 89 3 74 56 82 89 87 66
10
79 23 29 19 38 15 14 33 85 1...

output:

2 1 7 8 8 6 3 7 3 6 4 5 1 4 4 1 2 4 3 2 3 2 4 7 8 6 6 3 3 7 1 6 5 2 8 7 2 8 4 2 1 2 2 8 7 9 2 4 4 8 4 6 2 2 7 2 2 3 2 6 7 8 3 1 2 1 8 3 5 7 1 5 5 2 1 7 8 7 7 1 6 3 5 6 4 10 8 7 2 7 4 7 8 3 2 1 7 7 3 4 1 10 7 6 3 5 5 6 4 9 8 9 2 1 3 3 3 1 4 4 3 2 2 5 6 7 7 7 2 10 1 9 4 9 2 9 8 9 5 5 10 2 5 8 4 4 4 9 ...

result:

wrong answer Test case #1, Query #1, Your answer is not good enough

Subtask #4:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

input:

4 100
450
10
30.37 69.63 50.77 49.23 94.68 5.32 36.02 63.98 30.92 69.08 60.25 39.75 94.63 5.37 61.38 38.62 91.27 8.73 28.94 71.06
8
74.79 25.21 8.63 91.37 49.25 50.75 27.02 72.98 72.03 27.97 52.44 47.56 41.20 58.80 44.26 55.74
9
58.02 41.98 35.82 64.18 99.61 0.39 59.26 40.74 47.09 52.91 87.65 12.35 ...

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 205ms
memory: 5960kb

input:

5 100
400
9
1.57 81.69 17.89 66.70 65.51 20.96 14.19 70.10 73.04 13.58 25.01 60.09 57.73 28.55 18.21 66.41 41.57 44.34
8
42.15 15.21 45.93 11.16 27.62 30.65 39.90 17.60 9.87 47.93 51.17 5.44 14.72 43.43 42.11 15.26
9
15.72 52.00 32.33 36.33 7.60 59.51 39.83 28.78 58.75 9.42 30.01 38.51 24.14 44.06 0...

output:

1 5 8 6 3 5 8 5 3 9 1 1 3 5 6 6 1 1 7 3 7 2 3 5 1 4 9 2 7 8 7 4 1 8 8 1 2 7 5 3 2 1 7 8 8 8 1 3 2 1 3 10 8 2 5 3 6 4 3 5 10 3 2 5 1 1 2 8 3 3 5 5 6 1 5 2 2 6 3 1 2 2 7 2 6 3 7 5 3 4 3 3 8 6 7 3 5 9 8 9 6 1 1 5 1 3 2 3 6 2 1 8 7 6 3 6 10 5 5 6 9 8 1 6 7 4 3 3 5 6 2 4 9 6 6 3 9 7 6 1 4 2 2 7 9 2 9 9 3...

result:

wrong answer Test case #1, Query #4, Your answer is not good enough